w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the team which was defeated by Portugal in EURO cup 2016 final

SQL soccer Database: Subqueries Exercise-12 with Solution

12. Write a query in SQL to find the team which was defeated by Portugal in EURO cup 2016 final.

Sample table: soccer_country


Sample table: match_details


Sample Solution:

SQL Code:

SELECT country_name 
FROM soccer_country 
WHERE country_id=(
SELECT team_id 
FROM match_details 
WHERE play_stage='F'
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 team which was defeated by Portugal in EURO cup 2016 final - Duration

Rows:

Query visualization of Find the team which was defeated by Portugal in EURO cup 2016 final - Rows

Cost:

Query visualization of Find the team which was defeated by Portugal in EURO cup 2016 final - 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 match no, date of play and the 2nd highest stoppage time which have been added in the 2nd half of play.
Next: Write a query in SQL to find the club which supplied the most number of players to the 2016 EURO cup.

What is the difficulty level of this exercise?



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