w3resource
Soccer Database Exercises

SQL Subqueries exercises on soccer Database: Find the runners-up in Football EURO cup 2016

SQL soccer Database: Subqueries Exercise-24 with Solution

24. Write a query in SQL to find the runners-up in Football EURO cup 2016.

Sample table: match_details


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT country_name 
FROM soccer_country 
WHERE country_id=(
SELECT team_id 
FROM match_details 
WHERE play_stage='F' AND win_lose='L'
AND team_id<>(
SELECT country_id 
FROM soccer_country 
WHERE country_name='Portugal'));

Sample Output:

 country_name
--------------
 France
(1 row)

Query Visualization:

Duration:

Query visualization of Find the runners-up in Football EURO cup 2016 - Duration

Rows:

Query visualization of Find the runners-up in Football EURO cup 2016 - Rows

Cost:

Query visualization of Find the runners-up in Football 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 goalkeeper of the team Germany who didn't concede any goal in their group stage matches.
Next: Write a query in SQL to find the maximum penalty shots taken by the teams.

What is the difficulty level of this exercise?



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