SQL Having Clause

What is Having Clause?

A having clause is used when you want to give a where condition on such column on which aggregated function is applied.

The WHERE clause is used to specify a conditions on the selected columns, whereas the HAVING clause places conditions on groups created by the GROUP BY clause.

Syntax of Having Clause

SELECT column_name(s) FROM table_name
GROUP BY column_name(s)
HAVING condition;

Example of Having Clause

SELECT count(student_roll_no), student_name FROM student
GROUP BY student_name
HAVING count(student_roll_no)>1;
Previous Post Next Post

Contact Form