w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the teams who played the heighest audence match

SQL soccer Database: Subqueries Exercise-7 with Solution

7. Write a query in SQL to find the teams who played the heighest audence match.

Sample table: soccer_country


Sample table: goal_details


Sample table: match_mast


Sample Solution:

SQL Code:

SELECT country_name
FROM soccer_country
WHERE country_id IN(
   SELECT team_id 
   FROM goal_details 
   WHERE match_no=(
     SELECT match_no 
     FROM match_mast 
     WHERE audence=(
       SELECT max(audence) 
       FROM match_mast)
ORDER BY audence DESC));

Sample Output:

 country_name
--------------
 France
 Iceland
(2 rows)

Query Visualization:

Duration:

Query visualization of Find the teams who played the heighest audence match - Duration

Rows:

Query visualization of Find the teams who played the heighest audence match - Rows

Cost:

Query visualization of Find the teams who played the heighest audence match - Cost

Practice Online


Sample Database: soccer

soccer database relationship structure

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query in SQL to display the list of players scored number of goals in every matches.
Next: Write a query in SQL to find the player who scored the last goal for Portugal against Hungary.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming