1. Learn
  2. /
  3. Courses
  4. /
  5. Data Manipulation in SQL

Exercise

Correlated subquery with multiple conditions

Correlated subqueries are useful for matching data across multiple columns. In the previous exercise, you generated a list of matches with extremely high scores for each country. In this exercise, you're going to add an additional column for matching to answer the question -- what was the highest scoring match for each country, in each season?

*Note: this query may take a while to load.

Instructions

100 XP
  • Select the country_id, date, home_goal, and away_goal columns in the main query.
  • Complete the subquery: Select the matches with the highest number of total goals.
  • Match the subquery to the main query using country_id and season.
  • Fill in the correct logical operator so that total goals equals the max goals recorded in the subquery.