Google News
logo
Data Analyst - Interview Questions
What is the difference between a WHERE clause and a HAVING clause in SQL?

WHERE

HAVING

WHERE clause operates on row data. The HAVING clause operates on aggregated data.
In the WHERE clause, the filter occurs before any groupings are made.

HAVING is used to filter values from a group.

Aggregate functions cannot be used. Aggregate functions can be used.
Syntax of WHERE clause :
SELECT column1, column2, ...
FROM table_name
WHERE condition;?

Syntax of HAVING clause :
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);?
Advertisement