Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Top Server Configurations by Region
00:00
5 left

Top Server Configurations by Region

MediumSQL · PostgreSQL

Problem

Write a SQL query to find the top three highest-selling server configurations by region over the last quarter.

Use the sales, server_configurations, and regions tables. Interpret last quarter as the completed calendar quarter immediately before the current quarter.

Output

  1. One row per selected configuration and region, with region_name, configuration_name, total_units_sold, and sales_rank.
  2. Include no more than three configurations per region, ordered by region and descending sales rank.
  3. Break equal sales totals by configuration_name alphabetically.

Schema

sales
ColumnTypeDescription
sale_idPKINTUnique sales transaction identifier
region_idINTRegion associated with the sale
configuration_idINTServer configuration sold
sale_dateDATEDate of the sale
units_soldINTNumber of units sold in the transaction
server_configurations
ColumnTypeDescription
configuration_idPKINTUnique server configuration identifier
configuration_nameVARCHAR(100)Supermicro server configuration name
descriptionVARCHAR(255)Optional configuration description
regions
ColumnTypeDescription
region_idPKINTUnique sales region identifier
region_nameVARCHAR(100)Sales region name
Tablessalesserver_configurationsregions
Interviewer

Your question is Top Server Configurations by Region. Start with the requirements and the three tables 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.