SELECT MAX的COUNT

时间:2015-05-13 12:43:53

标签: mysql phpmyadmin

我查询显示正数和负数的总数,但我需要得到或只显示正数或负数的最大数。这是我的查询

SELECT count(`sentiment`) as count,`sentiment` FROM `sno_social_listener` WHERE `keyword_id` = 104 group by `sentiment`

1 个答案:

答案 0 :(得分:1)

ORDER BYLIMIT应该是您正在寻找的。

SELECT count(`sentiment`) as count,
       `sentiment` 
FROM `sno_social_listener` 
WHERE `keyword_id` = 104 
GROUP BY `sentiment` 
ORDER BY count DESC 
LIMIT 1