w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the number of penalty shots taken by the teams

SQL soccer Database: Exercise-26 with Solution

26. Write a query in SQL to find the number of penalty shots taken by the teams.

Sample table: soccer_country


Sample table: penalty_shootout


Sample Solution:

SQL Code:

SELECT a.country_name, COUNT(b.*) as "Number of Shots" 
FROM soccer_country a, penalty_shootout b
WHERE b.team_id=a.country_id
GROUP BY a.country_name;

Sample Output:

 country_name | Number of Shots
--------------+-----------------
 Poland       |               9
 Italy        |               9
 Germany      |               9
 Portugal     |               5
 Switzerland  |               5
(5 rows)

Query Visualization:

Duration:

Query visualization of Find the number of penalty shots taken by the teams - Duration

Rows:

Query visualization of Find the number of penalty shots taken by the teams - Rows

Cost:

Query visualization of Find the number of penalty shots taken by the teams - 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 prepare a list of players with number of shots they taken in penalty shootout matches.
Next: Write a query in SQL to find the number of booking happened in each half of play within normal play schedule.

What is the difficulty level of this exercise?



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