Assignment Query Desk
uses DISTINCT to reduce repeated country rows and show which nations reached the Final Four.
Query brief
Distinct countries represented in the Final Four.
capture the result grid in phpMyAdmin after running the query.
SELECT DISTINCT
s.season_label,
c.country_name
FROM team_seasons ts
INNER JOIN seasons s ON s.season_id = ts.season_id
INNER JOIN teams t ON t.team_id = ts.team_id
INNER JOIN countries c ON c.country_id = t.country_id
WHERE ts.final_four_flag = 1
ORDER BY s.season_id DESC, c.country_name ASC;
Live result
The query could not be executed: Expression #1 of ORDER BY clause is not in SELECT list, references column 'railway.s.season_id' which is not in SELECT list; this is incompatible with DISTINCT