[thelist] mySQL - limit by COUNT(*)?
Paul Cowan
evolt at funkwit.com
Wed Feb 5 23:24:01 CST 2003
R.Livsey wrote:
> SELECT COUNT(*) AS hits FROM requests WHERE hits>10 GROUP BY request
use HAVING. HAVING is like WHERE, but applied AFTER the aggregates
are applied, if you see what I mean. That's how I think of it, anyway.
You want:
[...] FROM requests GROUP BY request HAVING COUNT(*) > 10
which should do as you wish. You might be able to use
HAVING hits > 10
instead of
HAVING COUNT(*) > 10
but you may also not. You can't in MS SQL 7, anyway.
Hope this helps,
Paul
More information about the thelist
mailing list