从行中获取最高价值 - MySQL

时间:2012-08-24 21:29:25

标签: mysql sql count max

我有这个问题:

SELECT tag, filename, timecode, COUNT(tag) AS total 
FROM dados 
WHERE dados.tag = 'movie' 
AND dados.filename = 'movie2.mp4' 
GROUP BY timecode

这就是结果:

但我只想要第3行,更确切地说是时间码= 2,因为它是具有较高值的​​最具组成标记。 如何从这些行中获取最高时间码值?

1 个答案:

答案 0 :(得分:0)

ORDER BYLIMIT

一起使用
SELECT tag, filename, timecode, COUNT(tag) AS total 
FROM dados 
WHERE dados.tag = 'movie' 
AND dados.filename = 'movie2.mp4' 
GROUP BY timecode
ORDER BY COUNT(tag) DESC
LIMIT 1