w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the winner of EURO cup 2016

SQL soccer Database: Subqueries Exercise-2 with Solution

2. Write a query in SQL to find the winner of EURO cup 2016.

Sample table: soccer_country


Sample table: match_details


Sample Solution:

SQL Code:

SELECT country_name as Team 
FROM soccer_country 
WHERE country_id in (
SELECT team_id 
FROM match_details 
WHERE play_stage='F' and win_lose='W');

Sample Output:

   team
----------
 Portugal
(1 row)

Query Visualization:

Duration:

Query visualization of Find the winner of EURO cup 2016 - Duration

Rows:

Query visualization of Find the winner of EURO cup 2016 - Rows

Cost:

Query visualization of Find the winner of EURO cup 2016 - 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 find the teams played the first match of EURO cup 2016.
Next: Write a query in SQL to find the match with match no, play stage, goal scored, and the audence which was the heighest audence match.

What is the difficulty level of this exercise?



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