It is possible to operate a “selection” on groups rather than on rows using
the clause having. The condition that follows having must be formulated to
include only data that have an atomic character for every group.
Example 5.17.4 Let us determine the average grade obtained in courses that
are taken by more than two students. After grouping the tuples of GRADES on
cno, we retain the groups that include more than two students by applying the
clause having count(grade) > 2:
select cno, avg(grade) from GRADES
group by cno
having count(grade) > 2
order by cno;
This query returns the table: