Having SQL Tutorial

Having Syntax:

SELECT column_name(s), aggregate_function(column_name)
FROM my_table
WHERE condition {optional}
GROUP BY column_name(s)
HAVING (aggregate_function condition)

Having Example:

Sales table:

IDPRICECUSTOMER
1200David
2500Linda
3900Tom
4500David
51200Ellen
61200Linda

SELECT customer, SUM(price)
FROM sales
GROUP BY customer
HAVING SUM(price) > 1000

Having Result:

customerSUM(price)
Linda1700
Ellen1200