Back to project archive

09 · SQL analysis · Used-car listings

Automotive Industry Trends in India

A set of business-led SQL analyses exploring how price, mileage, specifications and usage vary across an Indian used-car listing dataset.

10documented analytical questions
4window-function patterns
±10%market-average price band
13listing attributes described

SQL organised around questions, not syntax

Each row is a used-car listing with fields including model, year, listed selling price, kilometres driven, fuel, seller type, transmission, ownership, mileage, engine, power, torque and seats.

The analysis starts with practical market questions and then selects the SQL needed to answer them. That keeps the work closer to an analyst’s workflow than a collection of disconnected query examples.

The dataset records listings and asking prices. It does not prove completed transactions, revenue or causal market effects.

From segments to movement within a model

PRICE

Fuel and ownership

Compare average listed price for first-owner manual vehicles by fuel type.

UTILITY

Larger vehicles

Identify high-mileage models among vehicles with more than five seats.

SPREAD

Within-model variation

Find models with a large gap between minimum and maximum listed price.

BENCHMARK

Price near average

Isolate listings within ten percent of the dataset-wide mean.

Other questions examine above-average price combined with below-average mileage, cumulative listed value by model year, price decreases relative to the previous observation and total recorded kilometres by transmission type.

Increasing complexity only when the question needs it

01
Filter and aggregateWHERE, GROUP BY and HAVING establish the core segments.
BASE
02
Benchmark with subqueriesIndividual listings are compared with global averages.
COMPARE
03
Stage logic with CTEsIntermediate summaries support a second analytical step.
COMPOSE
04
Keep row detail with windowsCumulative sums and running averages avoid collapsing records.
ANALYSE
05
Compare and rankLAG and RANK expose ordered relationships.
ORDER

The running average is documented accurately as cumulative or expanding. Although an original comment called it an exponential moving average, the SQL applies equal weight to all preceding rows and is therefore not a true EMA.

Caveats kept beside the analysis

Large price spreads within a model may reflect different years, trims, condition or specification. A price decline relative to the previous ordered row is an observation within the listing data, not proof of depreciation.

The final ranking query also has a known limitation: partitioning by model ranks within each model rather than isolating the three highest-priced models overall. Calling that out is more useful than presenting an incorrect top-three claim.

SQLCTEsSubqueriesWindow functionsLAGRANKPricing analysisEDA

A clear route from exercise to fuller model

Natural next steps include normalising vehicle, model, seller and specification entities; adding manufacturer-level analysis; implementing a true EMA; and correcting the global top-three ranking.

Data-quality checks for missing, duplicated or inconsistent attributes would strengthen the import layer, while Power BI could make the verified query outputs easier to explore.

Next case studyBangalore Accident Analysis