Difference between HAVING and WHERE Clause

 Posted by Sathya4260 on 2/19/2011 | Category: Sql Server Interview questions | Views: 71901 | Points: 40
Answer:

Where Clause:
1.Where Clause can be used other than Select statement also
2.Where applies to each and single row
3.In where clause the data that fetched from memory according
to condition
4.Where is used before GROUP BY clause
Ex:Using Condition for the data in the memory.

Having Clause:
1.Having is used only with the SELECT statement.
2.Having applies to summarized rows (summarized with GROUP BY)
3.In having the completed data firstly fetched and then separated according to condition.
4.HAVING clause is used to impose condition on GROUP Function and is used after GROUP BY clause in the query
Ex: when using the avg function and then filter the data like ava(Sales)>0

Summary:
Having works like Where clause with out Group By Clause


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Jatinnahar15 on: 4/21/2011 | Points: 10
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
Posted by: Jatinnahar15 on: 4/21/2011 | Points: 10
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

Login to post response