w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find those two teams which scored three goals in a single game at this tournament

SQL soccer Database: Joins Exercise-27 with Solution

27. Write a query in SQL to find those two teams which scored three goals in a single game at this tournament.

Sample table: match_details


Sample table: soccer_country


Sample Solution:

SQL Code:

SELECT match_no,country_name
FROM match_details a
JOIN soccer_country b
ON a.team_id=b.country_id
WHERE goal_score=3  AND win_lose='D';

Sample Output:

 match_no | country_name
----------+--------------
       34 | Hungary
       34 | Portugal
(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 the oldest player to have appeared in a EURO cup 2016 match.
Next: 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.

What is the difficulty level of this exercise?



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