Practice · Agriculture · Medium
For each year present, return the year and the summed million_tonnes across all crops as total (2 decimals), oldest year first.
Runs in your browser. No signup needed.
crops(crop, year, million_tonnes). GROUP BY year.
SELECT year, ROUND(SUM(million_tonnes), 2) AS total
FROM crops
GROUP BY year
ORDER BY year;
The reference solution is checked automatically when you run your query on the practice page — results are compared row by row, and order matters for this one.
Grouping by a shared dimension (here, year) is how you turn a long, thin table into a summary. (SQLite docs)