having count mysql code example
Example 1: SQL only show where count is great than 1
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;
Example 3: mysql HAVING
SELECT colonne1, SUM(colonne2)
FROM nom_table
GROUP BY colonne1
HAVING fonction(colonne2) operateur valeur