S.No. | WHERE | HAVING |
1 | WHERE clause can be used with a Select, Update and Delete Statement Clause. | HAVING clause can be used only with a Select statement. |
2 | WHERE clause doesn’t allow the use of aggregate functions except in subqueries contained in HAVING clause. | HAVING clause allow the use of aggregate functions. Column name contained in GROUP BY clause can be used in HAVING clause. |
3 | WHERE is a Pre-Filter and used before the GROUP BY clause. | HAVING is Post-Filter and used after the GROUP BY clause in the query to impose a condition on the GROUP function to filter the data. |
4 | WHERE clause applies to each and every row. WHERE is used to filter the single record of the table. | HAVING clause applies to summarized rows with GROUP BY. HAVING is used to filter groups. |
5 | WHERE clause fetches the data from memory depending on a condition. | HAVING clause uses the fetched data first and then filter it depending on the condition. |
6 | Syntax: SELECT column 1, column 2, … column n FROM table_name WHERE [conditions] | Syntax: SELECT column 1, column 2, …column n FROM table_name WHERE[conditions] GROUP BY column_name(s) |