sql question

Mike Starke plug-discuss@lists.plug.phoenix.az.us
Thu, 27 Mar 2003 19:20:33 -0500


On Thu, Mar 27, 2003 at 03:25:50PM -0700, az_pete@cactusfamily.com wrote:
/_SELECT a, COUNT(a) AS b FROM tbl WHERE b > 1 GROUP BY a
/_should be 
/_SELECT a, COUNT(a) AS b FROM tbl  GROUP BY a having b > 1
/_
/_where clauses cannot act on aggregate functions (count, sum, avg, etc).
/_to filter on aggregate functions you must use the having clause
/_
/_HTH,
/_Peter

Why do I keep forgeting that? Thanks for the explanation.

-Mike