w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the number of goals Germany scored at the tournament

SQL soccer Database: Subqueries Exercise-17 with Solution

17. Write a query in SQL to find the number of goals Germany scored at the tournament.

Sample table: goal_details


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT COUNT(player_id) 
FROM goal_details 
WHERE team_id=
(
SELECT country_id 
FROM soccer_country
WHERE country_name='Germany'
);

Sample Output:

 count
-------
     7
(1 row)

Query Visualization:

Duration:

Query visualization of Find the number of Germany scored at the tournament - Duration

Rows:

Query visualization of Find the number of Germany scored at the tournament - Rows

Cost:

Query visualization of Find the number of Germany scored at the tournament - 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 goalkeeper for Italy in penalty shootout against Germany in Football EURO cup 2016.
Next: Write a query in SQL to find the players along with their jersey no., and playing club, who were the goalkeepers for the England squad for 2016 EURO cup.

What is the difficulty level of this exercise?



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