w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the teams with other information that finished bottom of their respective groups after conceding four times in three games

SQL soccer Database: Joins Exercise-28 with Solution

28. Write a query in SQL to find the teams with other information that finished bottom of their respective groups after conceding four times in three games.

Sample table: soccer_team


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT a.country_name as Team , b.team_group,b.match_played, 
b.goal_agnst, b.group_position 
FROM soccer_country a
JOIN soccer_team b
ON a.country_id=b.team_id
WHERE goal_agnst=4 AND group_position=4
ORDER BY team_group;

Sample Output:

  team   | team_group | match_played | goal_agnst | group_position
---------+------------+--------------+------------+----------------
 Romania | A          |            3 |          4 |              4
 Austria | F          |            3 |          4 |              4
(2 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 those two teams which scored three goals in a single game at this tournament.
Next: Write a query in SQL to find those three players with other information, who contracted to Lyon participated in the EURO cup 2016 Finals.

What is the difficulty level of this exercise?



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