snippet in sql
having vs where sql
The difference between the having and where clause in SQL is that the where clause cannot be used with aggregates(max, min,count,avg,sum) , but the having clause can.
SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country HAVING COUNT(CustomerID) > 5;
SELECT colonne1, SUM(colonne2) FROM nom_table GROUP BY colonne1 HAVING fonction(colonne2) operateur valeur
sql count having
SELECT COUNT( * ) FROM agents HAVING COUNT(*)>1; --count is greater than 1