我有一个包含某些字段的表格(trackid,artist,countview),我只需要返回最大countview
值的行。
尝试
SELECT trackid, artist, MAX(countview) FROM tracklist
但我觉得我应该穿上HAVING?
答案 0 :(得分:2)
SELECT trackid, artist, countview
FROM tracklist
ORDER BY countview DESC LIMIT 1
答案 1 :(得分:1)
SELECT trackid,artist FROM tracklist WHERE countview =(SELECT MAX(countview)FROM tracklist)
答案 2 :(得分:1)
SELECT trackid, artist, countview FROM tracklist ORDER BY countview DESC LIMIT 1
SELECT trackid, artist, countview FROM tracklist WHERE countview =(SELECT max(countview) FROM tracklist)
答案 3 :(得分:1)
SELECT *
FROM tracklist
WHERE countview = (SELECT MAX(countview) FROM tracklist)
答案 4 :(得分:0)
SELECT trackid,artist,MAX(countview)FROM tracklist GROUP BY trackid,artist