Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Running Totals Over Time

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

Your question is Running Totals Over Time. Start with the requirements and the two tables 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

Blend360 needs a revenue trend for its performance reporting dashboard. Write a PostgreSQL query that calculates daily settled revenue from completed orders and a chronological running revenue total.

Requirements

  1. Join completed orders to their settled payments.
  2. Aggregate payment amounts by order_date as daily_revenue.
  3. Calculate running_total across dates using a window function.
  4. Return one row per date, ordered from earliest to latest.

Schema

blend360_orders
ColumnTypeDescription
order_idPKINTUnique order identifier
order_dateDATEDate the order was placed
order_statusVARCHAR(20)Order lifecycle status
blend360_payments
ColumnTypeDescription
payment_idPKINTUnique payment identifier
order_idINTReferences blend360_orders.order_id
payment_amountDECIMAL(10,2)Amount processed for the payment
payment_statusVARCHAR(20)Payment processing status
payment_methodVARCHAR(30)Payment method used
Tablesblend360_ordersblend360_payments
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results