Thread: HAVING clause
View Single Post
  #2 (permalink)  
Old February 11th, 2004, 12:40 PM
Jeff Mason Jeff Mason is offline
Friend of Wrox
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post

The HAVING clause is a separate clause in the SELECT statement, similar to the WHERE clause. It works just like the WHERE clause, but it selects (grouped) rows after the GROUPing operation. The WHERE clause selects rows before GROUPing is done. Since COUNT is an aggregate function, you must use a GROUP by clause to arrange for rows to be grouped by the value of the 'email' column:
SELECT email FROM competition
   WHERE Answer='Ripple'
GROUP BY email
Jeff Mason
Custom Apps, Inc.
Reply With Quote