It is possible to use aggregate functions in computing rankings.
Example 5.18.2 To rank the students in order of the number of courses they
have taken we could write:
select STUDENTS.name, GA.noc as no_of_courses,
dense_rank() over (order by GA.noc desc) as den_rank
from (select stno, count(distinct cno) as noc
from grades
group by stno) GA, STUDENTS
where STUDENTS.stno = GA.stno;
This generates the result: