Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Sum From 1 to 1,000,000
00:00
5 left

Sum From 1 to 1,000,000

EasySQL · PostgreSQL

Problem

Virtu Financial's Triton platform maintains a validation table containing integer sequence values used in data-quality checks. Write a PostgreSQL query to calculate the sum of every integer from 1 through 1,000,000, inclusive.

The sequence_values table contains one row for each required integer. It may also contain NULL values or values outside the target range, which must not affect the result.

Requirements

  1. Sum only values between 1 and 1,000,000, inclusive.
  2. Return one row with the result under the alias total_sum.

Schema

sequence_values
ColumnTypeDescription
value_idPKBIGINTUnique row identifier
sequence_valueINTEGERInteger value used in the validation sequence
Tablessequence_values
Interviewer

Your question is Sum From 1 to 1,000,000. Start with the requirements and the one table in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.