The Question : Aryan, a database administrator, has grouped records of a table with the help of group by clause. He needs to further filter groups of records generated through group by clause. Suggest suitable clause for it and properly explain its usage with the help of an example.
Solution for the question :
Having clause is used to further filter those groups of records which will be generated through the group by clause.
For example:
Select max(marks) from student group by classes having classes in (10,12);
Above given query will arrange records in groups according to the classes. Further filtering on these groups will happen through having clause, which will finally display the highest marks from classes 10 and 12.
The correct answer to the question is researched by our moderators and shared with you. You can give feedback by commenting for the answers you think are wrong.