BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Data Manipulation in SQL

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Complete the subquery to select the matches with the highest number of total goals.
  • Match the subquery to the main query using the country_id and season columns in both tables.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

SELECT 
	main.country_id,
    main.date,
    main.home_goal,
    main.away_goal
FROM match AS main
WHERE 
	-- Filter for matches with the maximum number of total goals scored
	(home_goal + away_goal) = 
        (SELECT ___(___ + sub.away_goal)
         FROM match AS sub
         -- Join the main query to the subquery in WHERE
         WHERE ___ = sub.___
               AND ___ = sub.___);
Kodu Düzenle ve Çalıştır