Having Vs Where clause

 There are the following difference between WHERE and HAVING clause:


WHERE ClauseHAVING Clause
1.WHERE Clause is used to filter the records from the table based on the specified condition.HAVING Clause is used to filter record from the groups based on the specified condition.
2.WHERE Clause can be used without GROUP BY ClauseHAVING Clause cannot be used without GROUP BY Clause
3.WHERE Clause implements in row operationsHAVING Clause implements in column operation
4.WHERE Clause cannot contain aggregate functionHAVING Clause can contain aggregate function
5.WHERE Clause can be used with SELECT, UPDATE, DELETE statement.HAVING Clause can only be used with SELECT statement.
6.WHERE Clause is used before GROUP BY ClauseHAVING Clause is used after GROUP BY Clause
7.
WHERE Clause is used with single row function like UPPER, LOWER etc.HAVING Clause is used with multiple row function like SUM, COUNT etc.

Continue Learning: SQL SELECT - DISTINCT, COUNT, SUM, IN, NULL

Comments

Popular Posts