Practice · Agriculture · Medium
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.
crops(crop, year, million_tonnes). GROUP BY crop, AVG(...), ORDER BY the average descending.
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.
Sugarcane dwarfs the grains by weight — but most of it becomes sugar, not calories on a plate. (FAOSTAT)