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 5Then 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
精彩评论