select distinct t.age, t.max_cnt from( select age, count(id) as max_cnt, dense_rank()over(partition by age order by count(id) desc) as pt from user_profile group by age,university ) as t where t.pt=1 order by max_cnt desc,t.age desc
select distinct t.age, t.max_cnt from( select age, count(id) as max_cnt, dense_rank()over(partition by age order by count(id) desc) as pt from user_profile group by age,university ) as t where t.pt=1 order by max_cnt desc,t.age desc