Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Total Sales by Region

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

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

Business Context

Blue Yonder Luminate Planning users need a regional view of sales performance for operational reporting. The source data contains one row per sales transaction.

Task

Write a PostgreSQL query that calculates total sales by region from the sales_transactions table.

Requirements

  1. Group transactions by region and calculate the sum of sale_amount for each region.
  2. Return all regions, including transactions where the region is unknown, and sort the results by total sales from highest to lowest.

Schema

sales_transactions
ColumnTypeDescription
transaction_idPKINTEGERUnique sales transaction identifier
regionVARCHAR(50)Sales region associated with the transaction
sale_amountDECIMAL(12,2)Transaction sales amount
transaction_dateDATEDate of the sales transaction
Tablessales_transactions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results