为了获得以下结果集,我编写了以下 SQL:
SELECT t1.FilmName,
t2.CountryName,
t1.FilmRunTimeMinutes
FROM Film as t1
INNER JOIN country as t2 on t1.FilmCountryId = t2.CountryID
WHERE t1.FilmRunTimeMinutes = ( SELECT max(t2.FilmRunTimeMinutes)
FROM film as t2
WHERE t2.FilmCountryId = t1.FilmCountryId
)
ORDER BY FilmRunTimeMinutes DESC
Run Code Online (Sandbox Code Playgroud)
我阅读了此链接并尝试了相同的方法,但我做不到。那么如何使用 by 获得相同的结果集LEFT OUTER JOIN
?
电影表有这些列:
电影 ID --PK 影片名称 电影国家 ID --FK 电影运行时间
Country表有这些列:
CountryId --PK 国家的名字
提前致谢。