+ 2
What is the difference between Having and Where clause?
2 Answers
+ 2
where clause is used to filter out table rows to be queried based some conditions. Having clause is used when you use a group by some field, and you want filter the groups based on some criteria.
Let us take an example of student marks table which contains the following columns.
student ID, subject id, marks
and you want to filter the students whose total marks are greater than 300, you would write a query like this.
select student_id, sum(marks)
from marks
group by student_id
having sum(marks) > 300
+ 1
Thanks Ravi