IniziaInizia gratis

Getting started with nested subqueries

Time to take your subqueries up a gear! You only have time to watch so much soccer, and want to know if the England Premier League is exciting as people say.

You'll compare the maximum number of goals scored in a single match across each season against the maximum for the England Premier League.

Questo esercizio fa parte del corso

Data Manipulation in SQL

Visualizza il corso

Istruzioni dell'esercizio

  • Complete a nested subquery to select the country_id for 'England Premier League' from league, which will be used to filter the parent subquery.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

SELECT 
    season,
    MAX(home_goal + away_goal) AS max_goals,
    (SELECT MAX(home_goal + away_goal) 
     FROM match 
     WHERE season = main.season
     -- Subquery to get the max goals in an 'England Premier League' match for the same season
     AND country_id IN (____)
    ) AS pl_max_goals
FROM match AS main
GROUP BY season;
Modifica ed esegui il codice