Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Sum From 1 to 1,000,000

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Sum From 1 to 1,000,000. Start with the requirements and the one table on the right.

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.

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
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results