w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the player with other infromation Who scored the last goal in the 2nd semi final i.e. 50th match in EURO cub 2016

SQL soccer Database: Subqueries Exercise-20 with Solution

20. Write a query in SQL to find the player with other infromation Who scored the last goal in the 2nd semi final i.e. 50th match in EURO cub 2016.

Sample table: player_mast


Sample table: goal_details


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT a.player_name, b.goal_time, b.goal_half, c.country_name
FROM player_mast a, goal_details b,soccer_country c
WHERE a.player_id=b.player_id
AND b.team_id=c.country_id
AND match_no=50
AND goal_time= (
SELECT MAX(goal_time) 
FROM  goal_details 
WHERE match_no=50);

Sample Output:

    player_name     | goal_time | goal_half | country_name
--------------------+-----------+-----------+--------------
 Antoine Griezmann  |        72 |         2 | France
(1 row)

Query Visualization:

Duration:

Query visualization of Find the player with other infromation Who scored the last goal in the 2nd semi final i.e. 50th match in EURO cub 2016 - Duration

Rows:

Query visualization of Find the player with other infromation Who scored the last goal in the 2nd semi final i.e. 50th match in EURO cub 2016 - Rows

Cost:

Query visualization of Find the player with other infromation Who scored the last goal in the 2nd semi final i.e. 50th match in EURO cub 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 players with other information under contract to Liverpool were in the Squad of England in 2016 EURO cup.
Next: Write a query in SQL to find the player Who was the captain of the EURO cup 2016 winning team from Portugal.

What is the difficulty level of this exercise?



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