WHAT IS THE DIFFERENCE BETWEEN WHERE AND HAVING CLAUSE IN SQL

WHERE VS HAVING CLAUSE

WHERE VS HAVING CLAUSE IN SQL

S.No.WHEREHAVING
1WHERE clause can be used with a Select, Update and Delete Statement Clause.HAVING clause can be used only with a Select statement.
2WHERE 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.
3WHERE 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.
4WHERE 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.
5WHERE 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.
6Syntax: 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)
WHERE VS HAVING CLAUSE IN SQL

Leave a Reply

Your email address will not be published. Required fields are marked *