我想从我的数据库中返回最多eps的标题。 使用以下代码,我将获得所有标题。
SELECT titel, MAX(aantalafleveringen) FROM imdb.tvserie GROUP BY titel;
希望有人能解释我的错误。
答案 0 :(得分:1)
SELECT distinct titel, MAX(aantalafleveringen) over (partition by titel)
FROM imdb.tvserie
ORDER BY max desc
LIMIT 1
;
答案 1 :(得分:1)
使用Order by
和Limit
SELECT titel,
Max(aantalafleveringen) AS max_aantalafleveringen
FROM imdb.tvserie
GROUP BY titel
ORDER BY max_aantalafleveringen DESC -- orders the result in descending order
LIMIT 1 -- filters the first record
答案 2 :(得分:1)
如果您希望每组最多最多,那么您真的想要全局最大值。
这与其他答案相同,但更为简单:
SELECT titel, aantalafleveringen
FROM imdb.tvserie
ORDER BY aantalafleveringen DESC
LIMIT 1