Vehicle records per model year
BeginnerGROUP BYVehicle fuel economy (FuelEconomy.gov, model years 2010–2027)
Return each model year and how many vehicle records it has, in year order.
Solution
SELECT year, COUNT(*) AS n FROM vehicles GROUP BY year ORDER BY year;Expected output:
Hint
One row per year: GROUP BY year.
Same question in Excel / Google Sheets
PivotTable with year in Rows and Count of id.
Download the CSV from the datasets page. Column letters assume the CSV opens with its header in row 1.
Tip: Ctrl+Enter (⌘+Enter on Mac) checks your answer. Everything runs in your browser; nothing you type is sent anywhere.