What is Difference between Group by and Having Clause and where and Why we use that ??
please explain with Sql Query.
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.
TanlinPosted May 28, 2012, 1:54 AM
SELECT student_name, SUM(score)
FROM test_scores
GROUP BY student_name;
HAVING is a condition that can be placed on top of an aggregate function. In the above example, you can add "HAVING SUM(score) > 300" at the end of the query so the query only returns students whose total score is higher than 300.
Sam HobbsPosted May 14, 2011, 6:40 PM
The following three C# Corner articles might also help.
Vilas GitePosted May 14, 2011, 6:23 AM
please refer:
http://www.sql-tutorial.net/SQL-HAVING.asp
http://www.sql-tutorial.net/SQL-GROUP-BY.asp
Dorababu MekaPosted May 12, 2011, 3:51 AM
GROUP BY combines those rows into groups
HAVING filters groups
check the following for reference and example
http://www.w3schools.com/sql/sql_groupby.asp
http://www.w3schools.com/sql/sql_having.asp