Friday, October 14, 2011

diff bet having and where clause

Where clause does not work with aggregate wher having clause work.

Aggregate - sum ,max ,min ,Avg function

Solution Second

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