w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the team(s) who conceded the most goals in EURO cup 2016

SQL soccer Database: Joins Exercise-20 with Solution

20. Write a query in SQL to find the team(s) who conceded the most goals in EURO cup 2016.

Sample table: soccer_team


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT country_name,team_group,match_played,
won,lost,goal_for,goal_agnst
FROM soccer_team 
JOIN soccer_country 
ON soccer_team.team_id=soccer_country.country_id
WHERE goal_agnst=(
SELECT MAX(goal_agnst) 
FROM soccer_team);

Sample Output:

 country_name | team_group | match_played | won | lost | goal_for | goal_agnst
--------------+------------+--------------+-----+------+----------+------------
 Russia       | B          |            3 |   0 |    2 |        2 |          6
(1 row)

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 match where no stoppage time added in 1st half of play.
Next: Write a query in SQL to find the match where highest stoppege time added in 2nd half of play.

What is the difficulty level of this exercise?



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