Revolving around the core of technology
|Subject:||Using HAVING clause in SQL|
|Creation date:||7/29/09 3:29 PM|
|Last modified on:||7/29/09 3:29 PM|
The HAVING clause is used in combination with the GROUP BY clause. It can be used in a SELECT statement to filter the records that a GROUP BY returns. For example:
SELECT department, SUM(sales) as "Total sales"
GROUP BY department
HAVING SUM(sales) > 1000
The above example list all the departments that have over $1,000 in sales.
Do you have a helpful tip related to this document that you'd like to share with other users?