WHERE and HAVING clause in SQL ?
The WHERE clause is commonly used for implementing conditions on each tuple of the relation.
The HAVING clause is used in combination along with the GROUP BY clause. It can be used in a SELECT statement to filter groups of the records which a GROUP BY returns.
The syntax for the HAVING clause is:
SELECT column1, column2, ... column_n, aggregate_function (expression)
FROM tables
WHERE predicates
GROUP BY column1, column2, ... column_n
HAVING condition1 ... condition_n;
Aggregate_function can be a function such as SUM, COUNT, MIN, or MAX.
WHERE and HAVING clause in SQL.