What is Difference between Group by and Having Clause and where and Why we use that ??
please explain with Sql Query.
Group By and Having Clause
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dorababu MekaRank #457 · 5.5K reputationPosted May 11, 2011, 11:51 PM EDT
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
Vilas GiteRank #951 · 2.1K reputationPosted May 14, 2011, 2:23 AM EDT
please refer:
http://www.sql-tutorial.net/SQL-HAVING.asp
http://www.sql-tutorial.net/SQL-GROUP-BY.asp
Sam HobbsRank #107 · 20.5K reputationPosted May 14, 2011, 2:40 PM EDT
The following three C# Corner articles might also help.
Tanlin2 reputationPosted May 27, 2012, 9:54 PM EDT
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.