Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Running Sales Totals by Region
00:00
5 left

Running Sales Totals by Region

EasySQL · PostgreSQL

Problem

Walmart Marketplace analysts need a regional view of recent sales performance. Using the reporting date of 2025-03-15, write a PostgreSQL query that calculates daily sales and a running 30-day total for each region.

Requirements

  1. Include sales from 2025-02-14 through 2025-03-15, inclusive.
  2. Exclude rows with a missing region.
  3. Aggregate multiple sales records on the same region and date into daily sales.
  4. Use a window function to calculate the cumulative sales total independently for each region, ordered by sale date.

Schema

marketplace_sales
ColumnTypeDescription
sale_idPKINTUnique sale identifier
regionVARCHAR(50)Walmart Marketplace sales region
sale_dateDATEDate when the sale occurred
sales_amountNUMERIC(12,2)Sale amount in dollars
Tablesmarketplace_sales
Interviewer

Your question is Running Sales Totals by Region. 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.