When do you use HAVING clause in an SQL query code example
Example 1: sql count having
SELECT COUNT( * )
FROM agents
HAVING COUNT(*)>1; --count is greater than 1
Example 2: having in mysql
SELECT
ordernumber,
SUM(quantityOrdered) AS itemsCount,
SUM(priceeach*quantityOrdered) AS total
FROM
orderdetails
GROUP BY
ordernumber
HAVING
total > 1000;