Jainam Gala

SQL case study · MySQL 8.0

US Used Car Market Warehouse

Salvage titles sell for 87% less: $2,425 versus an $18,000 median. The warehouse is a star schema of 2,499 auction listings and 41,804 EPA records, with every removed row logged.

← Back to Portfolio

The data

SourceRowsWhat it adds
US Cars auction listings2,499Price, mileage, model year, title status, state
EPA fuel economy data41,804Fuel economy, vehicle class and fuel type for every make and model year, 1984–2020

fact_listings holds one clean listing. dim_location holds state and Census region. dim_make_year holds EPA specs rolled up to make and model year. dq_removed_rows logs every removed row and the reason.

stg_listings stg_epa_vehicles transform.sql fact_listings one clean listing dq_removed_rows dim_location dim_make_year
Staging tables on the left. The gold step is the cleaning script. The fact table sits in the center of the star.

Cleaning

StepRows
Raw listings2,499
Placeholder prices under $100, such as $0 and $25 opening bids−64
Non-passenger vehicles (Peterbilt, Harley-Davidson, Heartland RVs)−10
Canadian listings−7
Impossible mileage (0 miles or over 500,000)−4
Duplicate rows−1
Clean listings2,413
2,520 2,380 2,499 −64 −10 −7 −4 −1 2,413 Raw Price Not a car Canada Mileage Duplicate Clean
The axis starts at 2,380 so the 86 removed rows are visible. Navy is the start and the 2,413 rows kept.

Two columns were left out of the analysis. condition is auction time left, such as “2 days left” (832 rows) and “21 hours left” (492 rows). model is unreliable: its most common values are “door” (651), “doors” (148) and “mpv” (87). The EPA join uses make and model year.

2,412 of 2,413 clean listings matched on make and year. The miss is a 1973 Chevrolet, older than the EPA file, which starts in 1984.

Findings

Title status is the biggest price gap

A salvage title cuts the median from $18,000 to $2,425, a drop of 86.5%. That is a wider gap than any mileage band or model year. Clean titles are 2,318 listings. Salvage titles are 95.

$20K $0 $18,000 $2,425 Clean n = 2,318 Salvage n = 95
Column height is the median price. The results give medians and counts, not the quartile spread, so this is a median comparison rather than a box plot.

Price falls with mileage, steepest in the first 50,000 miles

On clean titles, the first extra 25,000 miles take about $8,200, or 33%, off the median. After 100,000 miles the price flattens. Across individual listings the correlation is r = −0.33.

MileageListingsMedian price
Under 25K729$24,700
25K–50K948$16,500
50K–100K431$13,200
100K–150K168$7,800
150K+42$7,160
$28K $0 −$8,200 Under 25K$24,700 25–50K$16,500 50–100K$13,200 100–150K$7,800 150K+$7,160
Each point is the median for that mileage band, clean titles only. The listing-level correlation is r = −0.33. Individual cars are not plotted, because the results note gives the five medians rather than every listing.

Depreciation by age

On clean titles, the steep drops are year 2 (−27.6%) and years 6 and 7 (−27.3% and −34.4%). Age 0 is cheaper than age 1, and only 47 cars are 2020 models, so that bump is noise.

$25K $0 −27.6% −34.4% 012345678+
Median price by age in years, clean titles. Copper marks the two steep drops. Age 8+ is $6,700. The y-axis runs from $0 to $25,000.

The Midwest premium is a mix of newer, lower-mileage cars

Midwest listings average $23,147, about $5,400 above the South. Those Midwest cars average 36,000 miles and 2.5 years old. Texas, the cheapest state in the file at $14,460, averages 68,000 miles and 3.8 years. The gap is which cars are listed where.

Midwest, n = 556 $23,147 Northeast, n = 489 $20,759 West, n = 358 $19,520 South, n = 915 $17,697
Average price, clean titles. Bar length is dollars, scaled to the Midwest. A state map is not drawn: the results note gives these four regions and Texas, not a price for every state.

Nissan is young and cheap

Among brands with 30 or more clean listings, Nissan cars are the youngest and least driven, and still about $10,000 below Ford. A brand’s EPA lineup fuel economy has only a weak link to price (r = −0.15). Price tracks mileage (r = −0.33) and model year (r = +0.23) more closely.

$26K $10K 35K miles 58K miles Ford Dodge Chevrolet Nissan GMC
Horizontal position is average mileage. Height is average price. Bubble size is the number of clean listings. Nissan sits low despite low mileage.
50% Ford
  • Ford, 50.0%
  • Dodge, 17.5%
  • Nissan, 12.9%
  • Chevrolet, 11.3%
  • All others, 8.3%
Share of clean listings. Half the file is Ford, so brand and regional averages lean that way.

Limits

What the SQL demonstrates

Project files

View the GitHub repository
← Back to Portfolio