SQL Exercise: Stadium hosted the final match of EURO cup 2016
SQL soccer Database: Joins Exercise-13 with Solution
13. From the following tables, write a SQL query to find out which stadium hosted the final match of the 2016 Euro Cup. Return venue_name, city, aud_capacity, audience.
Sample table: soccer_venue
Sample table: soccer_city
Sample table: match_mast
Sample Solution:
SQL Code:
SELECT a.venue_name, b.city, a.aud_capacity, c.audence
FROM soccer_venue a
JOIN soccer_city b ON a.city_id=b.city_id
JOIN match_mast c ON a.venue_id=c.venue_id
WHERE play_stage='F';
Sample Output:
venue_name | city | aud_capacity | audence -----------------+-------------+--------------+--------- Stade de France | Saint-Denis | 80100 | 75868 (1 row)
Code Explanation:
The said query in SQL that selects the name of the venue where the final is played, the city in which the venue is located, the capacity of the venue, and the audience count for all matches in the "Finals" stage from the tables soccer_venue, soccer_city, and match_mast.
The JOIN keyword is used to join the tables together based on their city_id and venue_id columns.
The JOIN keyword is used to join soccer_venue with soccer_city on their city_id columns, and then join the resulting table with match_mast on their venue_id columns.
The WHERE keyword is used to filter records for matches in the "Finals" stage.
Relational Algebra Expression:
Relational Algebra Tree:
Practice Online
Sample Database: soccer

Query Visualization:
Duration:

Rows:

Cost:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous SQL Exercise: City where the opening match of EURO cup 2016 played.
Next SQL Exercise: Number of matches played at each venue and their city.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
SQL: Tips of the Day
What is the best way to paginate results in SQL Server?
SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY OrderDate ) AS RowNum, * FROM Orders WHERE OrderDate >= '1980-01-01' ) AS RowConstrainedResult WHERE RowNum >= 1 AND RowNum < 20 ORDER BY RowNum
Database: SQL Server
Ref: https://bit.ly/3MGrNlk
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook