Top Farm per Crop
Medium
Crop Yield Analysis
For each crop return the farm with the highest total tons across all years. Include all farms tied for first. Order by crop.
Table schema
Farms(farm_id INT PRIMARY KEY, name VARCHAR(20), region VARCHAR(10))
Harvests(harvest_id INT PRIMARY KEY, farm_id INT, crop VARCHAR(10), year INT, tons INT, hectares INT)Sample data
Farms
farm_id | name | region
1 | Green Acres | North
2 | Sun Fields | North
3 | River Bend | South
Harvests
harvest_id | farm_id | crop | year | tons | hectares
1 | 1 | Wheat | 2024 | 100 | 20
2 | 1 | Wheat | 2025 | 120 | 20
3 | 2 | Rice | 2025 | 90 | 10
4 | 2 | Wheat | 2025 | 60 | 10
5 | 3 | Rice | 2024 | 80 | 16
6 | 3 | Rice | 2025 | 64 | 16
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.