我可以将结果限制为sql中的特定数字吗?

时间:2011-08-04 08:16:09

标签: mysql

Select count(*) as c from casting where ord = 1 Group by actorid Order by count(*) DESC 

结果是
15 15 14 13 12 10 7 7 7 7 5 5

然后我想得到的结果只有大于10 ??感谢~~

3 个答案:

答案 0 :(得分:3)

SELECT count(*) AS c 
FROM casting 
WHERE ord = 1 
GROUP BY actorid 
HAVING c > 10
ORDER BY c DESC

您可以考虑HAVING WHERE聚合的GROUP BY子句。

答案 1 :(得分:2)

SELECT COUNT(*) AS c FROM casting WHERE ord = 1 GROUP BY actorid HAVING COUNT(*) > 10 ORDER BY COUNT(*) DESC

答案 2 :(得分:1)

HAVING c > 10

将其放在group by和

之间