w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the number of players played for france in the final

SQL soccer Database: Subqueries Exercise-22 with Solution

22. Write a query in SQL to find the number of players played for france in the final.

Sample table: player_in_out


Sample table: match_mast


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT COUNT(*)+11 as "Number of players shared fields" 
FROM player_in_out 
WHERE match_no=(
SELECT match_no 
FROM match_mast 
WHERE play_stage='F')
AND in_out='I' 
AND team_id=(
SELECT country_id 
FROM soccer_country 
WHERE country_name='France');

Sample Output:

 Number of players shared fields
---------------------------------
                              14
(1 row)

Query Visualization:

Duration:

Query visualization of Find the number of players played for france in the final - Duration

Rows:

Query visualization of Find the number of players played for france in the final - Rows

Cost:

Query visualization of Find the number of players played for france in the 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 player Who was the captain of the EURO cup 2016 winning team from Portugal.
Next: Write a query in SQL to find the goalkeeper of the team Germany who didn't concede any goal in their group stage matches.

What is the difficulty level of this exercise?



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