HAVING is use with GROUP BY because WHERE condition not use with query
HAVING Syntax
SELECT ColName
FROM TableName
WHERE ColName
GROUP BY ColName
HAVING Condition
ORDER BY ColName
Example
SELECT COUNT(EmpID) FROM EmployeeMaster
GROUP BY Country
HAVING COUNT(EmpID) > 1
above query return number of employee in each country (only add countries with more than 1 employee)
HAVING Syntax
SELECT ColName
FROM TableName
WHERE ColName
GROUP BY ColName
HAVING Condition
ORDER BY ColName
Example
SELECT COUNT(EmpID) FROM EmployeeMaster
GROUP BY Country
HAVING COUNT(EmpID) > 1
above query return number of employee in each country (only add countries with more than 1 employee)