SQL ‘HAVING’ Statement

SQL HAVING Clause

SQL HAVING Clause

The SQL HAVING clause is used to filter data based on the group functions.

SQL HAVING Clause

The HAVING clause was added to SQL because the WHERE keyword could not 

be used with aggregate functions.

SQL HAVING Syntax

SELECT column_ name, aggregate _function(column_name) FROM table_name

WHERE column_name operator value GROUP BY column_ name HAVING 

aggregate _function(column_name) operator value

SQL HAVING EXAMPLE

SELECT Customer, SUM(OrderPrice) FROM Orders GROUP BY Customer 

HAVING SUM(OrderPrice)

SQL HAVING RESULT

Customer               SUM(OrderPrice)

Brown 1800

Leave a Reply

Your email address will not be published. Required fields are marked *