Practice · Agriculture · Medium

Average output per crop

For each crop, return the crop and its average million_tonnes across years as avg_mt (2 decimals), highest average first.

Runs in your browser. No signup needed.

What you are given

crops(crop, year, million_tonnes). GROUP BY crop, AVG(...), ORDER BY the average descending.

Starting point

SELECT crop, ROUND(AVG(million_tonnes), 2) AS avg_mt
FROM crops
GROUP BY crop
ORDER BY avg_mt DESC;

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

Sugarcane dwarfs the grains by weight — but most of it becomes sugar, not calories on a plate. (FAOSTAT)

More Agriculture challenges

Open it in the playground →