Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Analyze Outlet Sales by Region

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

Your question is Analyze Outlet Sales by Region. Start with the requirements and the three 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

You are given sales activity from Coca-Cola Consolidated outlets and asked to turn it into actionable insight. Write a PostgreSQL query that returns, for each region and month in Q1 2024, the total revenue, total units sold, number of active outlets with at least one completed sale, and an insight label showing whether the region is Growing, Declining, or Flat compared with the prior month based on revenue. Only include completed sales in the analysis.

Schema

ccc_regions
ColumnTypeDescription
region_idPKINTUnique region identifier
region_nameVARCHAR(50)Coca-Cola Consolidated region name
ccc_outlets
ColumnTypeDescription
outlet_idPKINTUnique outlet identifier
outlet_nameVARCHAR(100)Outlet name
region_idINTRegion assigned to the outlet
outlet_typeVARCHAR(30)Outlet channel type
opened_dateDATEOutlet opening date
ccc_sales
ColumnTypeDescription
sale_idPKINTUnique sale identifier
outlet_idINTOutlet where the sale occurred
sale_dateDATEDate of sale
units_soldINTCases sold
revenueDECIMAL(10,2)Revenue from the sale
sale_statusVARCHAR(20)Sale status
Tablesccc_regionsccc_outletsccc_sales
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results