w3resource
Soccer Database Exercises

SQL Joins exercises on soccer Database: Find the results of penalty shootout matches

SQL soccer Database: Joins Exercise-59 with Solution

59. Write a query in SQL to find the results of penalty shootout matches.

Sample table: match_details


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT match_no,
       play_stage,
       country_name,
       penalty_score
FROM match_details a
JOIN soccer_country b ON a.team_id=b.country_id
WHERE decided_by='P'
ORDER BY match_no;

Sample Output:

 match_no | play_stage | country_name | penalty_score
----------+------------+--------------+---------------
       37 | R          | Poland       |             5
       37 | R          | Switzerland  |             4
       45 | Q          | Poland       |             3
       45 | Q          | Portugal     |             5
       47 | Q          | Germany      |             6
       47 | Q          | Italy        |             5
(6 rows)

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 position of a player to play who scored own goal.
Next: Write a query in SQL to find the goal scored by the players according to their playing position.

What is the difficulty level of this exercise?



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