WinSQL » 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


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?

Important: This area is reserved for useful tips. Therefore, do not post any questions here. Instead, use our public forums to post questions.


Social Media

Powered by