Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Top 10 Selling Cars

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

Your question is SQL Top 10 Selling Cars. 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

CarGurus wants to identify the vehicle models with the highest number of completed sales through its marketplace. Write a PostgreSQL query to return the top 10 models sold during 2025.

Requirements

  1. Join vehicle models, CarGurus listings, and sales records.
  2. Include only completed sales made from January 1 through December 31, 2025.
  3. Return the make, model, number of completed sales, and average sale price for each model.
  4. Sort by completed sales descending, then average sale price descending, and return at most 10 models.

Schema

vehicle_models
ColumnTypeDescription
model_idPKINTUnique vehicle model identifier
makeVARCHAR(50)Vehicle manufacturer
modelVARCHAR(80)Vehicle model name
trimVARCHAR(80)Vehicle trim designation
listings
ColumnTypeDescription
listing_idPKINTUnique vehicle listing identifier
model_idINTReferenced vehicle model
marketplaceVARCHAR(40)Marketplace associated with the listing
listing_statusVARCHAR(20)Current listing status
sales
ColumnTypeDescription
sale_idPKINTUnique sale identifier
listing_idINTReferenced vehicle listing
sold_atDATEDate on which the vehicle was sold
sale_statusVARCHAR(20)Outcome of the sale transaction
sale_priceNUMERIC(10,2)Final transaction price
Tablesvehicle_modelslistingssales
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results