Sunday, April 24, 2016

Difference HAVING vs WHERE




WHERE
HAVING
1.
used as a filter condition in SELECT statements for selecting individual records.
used along with GROUP BY as a filter condition when group or aggregate functions are used in SELECT statement for selecting groups of data. 
2.
Can be used with Aggregate functions without GROUP BY
Can ONLY be used with GROUP BY
3.
The WHERE clause selects rows before grouping
The HAVING clause selects rows after grouping
4.
The WHERE clause cannot contain aggregate functions
The HAVING clause can contain aggregate functions



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.