|
Knowledge Base
Document information| Document ID: | 783 |
|---|
| Subject: | Using HAVING clause in SQL |
|---|
| Creation date: | 7/29/09 3:29 PM |
|---|
| Last modified on: | 7/29/09 3:29 PM |
|---|
Details
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" FROM order_details
GROUP BY department
HAVING SUM(sales) > 1000
The above example list all the departments that have over $1,000 in sales.
Add a comment to this document
Do you have a helpful tip related to this document that you'd like to share
with other users? Please add it below. Your name and tip will appear at the
end of the document text.
|