w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the teams that scored only one goal to the torunament

SQL soccer Database: Joins Exercise-16 with Solution

16.Write a query in SQL to find the teams that scored only one goal to the torunament.

Sample table: soccer_team


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT country_name as "Team" ,team_group, goal_for
FROM soccer_team
JOIN soccer_country 
ON soccer_team.team_id=soccer_country.country_id
AND goal_for=1;

Sample Output:

  Team   | team_group | goal_for
---------+------------+----------
 Albania | A          |        1
 Austria | F          |        1
 Sweden  | E          |        1
(3 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 player who was the first player to be sent off at the tournament EURO cup 2016.
Next: Write a query in SQL to find the yellow cards received by each country.

What is the difficulty level of this exercise?



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