GROUP BY multiple fields
GROUP BY becomes more powerful when used across multiple fields or combined with ORDER BY and LIMIT.
Perhaps you're interested in learning about budget changes throughout the years in individual countries. You'll use grouping in this exercise to look at the maximum budget for each country in each year there is data available.
This exercise is part of the course
Intermediate SQL
Exercise instructions
- Select the
release_year,country, and the maximumbudgetaliased asmax_budgetfor each year and each country; sort your results byrelease_yearandcountry.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Find the release_year, country, and max_budget, then group and order by release_year and country
___