w3resource
Soccer Database Exercises

SQL exercises on soccer Database: Find the teams played the match where 2nd highest stoppage time had been added in 2nd half of play

SQL soccer Database: Subqueries Exercise-10 with Solution

10. Write a query in SQL to find the teams played the match where 2nd highest stoppage time had been added in 2nd half of play.

Sample table: soccer_country


Sample table: match_details


Sample table: match_mast


Sample Solution:

SQL Code:

SELECT country_name 
FROM soccer_country 
WHERE country_id IN(
SELECT team_id 
FROM match_details 
WHERE match_no IN(
SELECT match_no 
FROM match_mast 
WHERE stop2_sec=(
SELECT max(stop2_sec) 
FROM match_mast
WHERE stop2_sec<>(
SELECT max(stop2_sec) 
FROM match_mast))));

Sample Output:

 country_name
--------------
 Albania
 France
(2 rows)

Query Visualization:

Duration:

Query visualization of Find the teams played the match where 2nd highest stoppage time had been added in 2nd half of play - Duration

Rows:

Query visualization of Find the teams played the match where 2nd highest stoppage time had been added in 2nd half of play - Rows

Cost:

Query visualization of Find the teams played the match where 2nd highest stoppage time had been added in 2nd half of play - Cost

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 2nd highest stoppage time which had been added in 2nd half of play.
Next: Write a query in SQL to find the match no, date of play and the 2nd highest stoppage time which have been added in the 2nd half of play.

What is the difficulty level of this exercise?



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