SQL Joins exercises on soccer Database: Find the team against which the penalty shot number 26 had been taken
SQL soccer Database: Joins Exercise-38 with Solution
38. Write a query in SQL to find the team against which the penalty shot number 26 had been taken.
Sample table: penalty_shootout
Sample table: soccer_country
SELECT match_no, country_name FROM penalty_shootout a JOIN soccer_country c ON a.team_id=c.country_id WHERE match_no= (SELECT match_no FROM penalty_shootout WHERE kick_id=26) AND country_name<> (SELECT country_name FROM soccer_country WHERE country_id= (SELECT team_id FROM penalty_shootout WHERE kick_id=26)) GROUP BY match_no, country_name;
match_no | country_name ----------+-------------- 47 | Germany (1 row)
Sample Database: soccer
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?