w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the player and his jersey number who scored the first penalty of the tournament

SQL soccer Database: Subqueries Exercise-14 with Solution

14. Write a query in SQL to find the player and his jersey number who scored the first penalty of the tournament.

Sample table: player_mast


Sample table: goal_details


Sample Solution:

SQL Code:

SELECT player_name,jersey_no 
FROM player_mast 
WHERE player_id=(
SELECT player_id 
FROM goal_details 
WHERE goal_type='P' AND match_no=(
SELECT MIN(match_no) 
FROM goal_details 
WHERE goal_type='P' AND play_stage='G'));

Sample Output:

  player_name   | jersey_no
----------------+-----------
 Bogdan Stancu  |        19
(1 row)

Practice Online


Sample Database: soccer

soccer database relationship structure

Query Visualization:

Duration:

Query visualization of Find the player and his jersey number who scored the first penalty of the tournament - Duration

Rows:

Query visualization of Find the player and his jersey number who scored the first penalty of the tournament - Rows

Cost:

Query visualization of Find the player and his jersey number who scored the first penalty of the tournament - Cost

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query in SQL to find the club which supplied the most number of players to the 2016 EURO cup.
Next: Write a query in SQL to find the player along with his team and jersey number who scored the first penalty of the tournament.

What is the difficulty level of this exercise?