Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL Top 10 Selling Cars
00:00
5 left

SQL Top 10 Selling Cars

MediumSQL · PostgreSQL

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
Interviewer

Your question is SQL Top 10 Selling Cars. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.