SQL Exercise: Where was the final match of the EURO cup 2016 held?
SQL soccer Database: Joins Exercise-1 with Solution
1. From the following table, write a SQL query to find out where the final match of the EURO cup 2016 was played. Return venue name, city.
Sample table: soccer_venue
Sample table: soccer_city
Sample table: match_mast
Sample Solution:
SQL Code:
SELECT venue_name, city
FROM soccer_venue a
JOIN soccer_city b ON a.city_id=b.city_id
JOIN match_mast d ON d.venue_id=a.venue_id
AND d.play_stage='F';
Sample Output:
venue_name | city -----------------+------------- Stade de France | Saint-Denis (1 row)
Code Explanation:
The given query in SQL that returns a list of all the venue names and their corresponding cities where matches with play_stage 'F' were held..
The query uses two JOIN operations to link the soccer_venue and soccer_city tables based on the common city_id column. It then uses a third JOIN operation to link the match_mast table with the previous result set based on the common venue_id column. The ON condition for this JOIN specifies that only rows where the play_stage column equals 'F' (which likely stands for "finals") are included in the final result set.
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: SQL JOINS Exercises on Soccer Database
Next SQL Exercise: Number of goals scored by each team in each match.
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