|
Can anybody explain to me the differences between Having and Where clauses ? And also can we use both within the same query ? Please give an example if possible. Thank you.
(comments are locked)
|
|
While they accomplish a very similar function, their uses are entirely different: First, a HAVING clause is only allowed / makes sense with a GROUP BY - which would typically imply you are using an aggregate of some sort in your SELECT statement. This also stems from the fact that in many cases aggregate functions are not allowed in the WHERE expression. Second, the following is the order in which key expressions of your statement are executed:
Allowing the data to first be refined by the FROM and the WHERE expressions allows for certain performance improvements when using the HAVING clause on a (potentially) smaller data set.
(comments are locked)
|
|
this is very good explanation, for easy and better explanation you can visit this link http://dotnetpeoples.blogspot.com/2011/04/having-clause-vs-where-clause.html
(comments are locked)
|

