The HAVING Clause enables you to specify conditions that filter which group results appear in the results.
SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s) HAVING condition ORDER BY column_name(s);
Let's put these statements into real use.
We've a table named Students in our database that contains the following records:
The following MySQL statement lists the number of Students in each Subject. Only include Subjects with more than 2 Students:
SELECT COUNT(ROLL_No), SUBJECT FROM Students GROUP BY SUBJECT HAVING COUNT(ROLL_No) > 1;
Now, after executing the above MySQL statement,