开发者

Can i limit my result to a specific number in sql?

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

The result is

15 15 14 13 12 10 7 7 开发者_StackOverflow7 7 5 5

Then i would like to get the result only greater than 10 ??how to do that thanks~~


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

You can consider HAVING the WHERE clause for GROUP BY aggregates.


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


HAVING c > 10

Place this between group by and order by

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜