I want to know what is the difference between a HAVING CLAUSE and WHERE CLAUSE in SQL server.
Thank you.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 29, 2012, 11:32 PM
Hi,
both, WHERE and HAVING clauses allow us to restrict the data you're selecting by establishing conditions.
Use HAVING instead of WHERE when you want to establish a condition that involves a grouping (aggregating) function like count(), max(), sum(), etc.
The WHERE clause is applied first to the individual rows in the tables
Please refer
http://www.codeproject.com/Articles/25258/Where-Vs-Having-Difference-between-having-and-Wher
http://blog.sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/
http://www.techonthenet.com/sql/having.php
hopr this will help you.
Satyapriya NayakPosted Jul 29, 2012, 2:44 PM
Specifies a search condition for a group or an aggregate. HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.
Thanks
Vilas GitePosted Jul 28, 2012, 4:22 AM
Just Watch & Implement queries.
http://www.youtube.com/watch?v=0EgAxYv-44o
http://www.w3schools.com/sql/sql_having.asp
http://www.w3schools.com/sql/sql_groupby.asp
Thanks..:)
Hardik PatelPosted Jul 28, 2012, 3:49 AM
1) where clause specifes the criteria which individual record must meet to be selected by query. it can be used without GROUP BY Clause. the HAVING Clause can not be used without GROUP BY Clause .
2) where clause can not contain aggregate function. Havng clause can contain aggregate function.
Santhosh Kumar JayaramanPosted Jul 28, 2012, 3:39 AM