我查询显示正数和负数的总数,但我需要得到或只显示正数或负数的最大数。这是我的查询
SELECT count(`sentiment`) as count,`sentiment` FROM `sno_social_listener` WHERE `keyword_id` = 104 group by `sentiment`
答案 0 :(得分:1)
ORDER BY
和LIMIT
应该是您正在寻找的。 p>
SELECT count(`sentiment`) as count,
`sentiment`
FROM `sno_social_listener`
WHERE `keyword_id` = 104
GROUP BY `sentiment`
ORDER BY count DESC
LIMIT 1