Practice · Agriculture · Medium

Total staple output per year

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.

What you are given

crops(crop, year, million_tonnes). GROUP BY year.

Starting point

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.

Did you know

Grouping by a shared dimension (here, year) is how you turn a long, thin table into a summary. (SQLite docs)

More Agriculture challenges

Open it in the playground →