Progress
SQL-92
Guide and Reference


HAVING CLAUSE

Allows you to set conditions on the groups returned by the GROUP BY clause. If the HAVING clause is used without the GROUP BY clause, the implicit group against which the search condition is evaluated is all the rows returned by the WHERE clause.

SYNTAX

HAVING search_condition 

NOTE: A condition of the HAVING clause can compare one aggregate function value with another aggregate function value or a constant.

EXAMPLE

The HAVING clause in the following example compares the value of an aggregate function
( COUNT (*) ) to a constant ( 10 ). The query returns the customer number and number of orders for all customers who had more than 10 orders before March 31st, 1999.

SELECT cust_no, count(*) 
     FROM orders 
     WHERE order_date < TO_DATE ('3/31/1999') 
     GROUP BY cust_no 
     HAVING COUNT (*) > 10 ; 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095