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

Connected

Exercise

Add a subquery to the SELECT clause

Subqueries in SELECT statements generate a single value that allow you to pass an aggregate value down a data frame. This is useful for performing calculations on data within your database.

In the following exercise, you will construct a query that calculates the average number of goals per match in each country's league.

Instructions

100 XP
  • In the subquery, Select the average total goals by adding home_goal and away_goal, then
  • Filter the results so that only the average of goals in the '2013/2014' season is calculated.
  • In the main query, select the average total goals by adding home_goal and away_goal. This calculates the average goals for each league, then
  • Filter the results in the main query the same way you filtered the subquery. GROUP the query BY the league name.