what is the difference between WHERE and HAVING clause. give three points.
Answers
Thanks for asking this Question.
Difference between Where and Having clause:
(i) Where clause - Filter rows.
(ii) Having clause - Filter groups
(i) Where clause - Filter data before group by
(ii) Having - Filter data after group by
(i) Where clause - Cannot contain aggregate functions
(ii) Having clause - can contain aggregate functions
Example using where,Group by Having clauses together:
Select deptno,sum(salary) from emp where deptno IN(10,20) Group by deptno having sum(salary) > 10000;
Output:
Deptno Sum(salary)
20 10875
Hope it helps!
A WHERE clause is used is filter records from a result. The filter occurs before any groupings are made.
A HAVING clause is used to filter values from a group.