Sql oracle查询以按类型从每个计数值组中查找最大数据

Sql oracle查询以按类型从每个计数值组中查找最大数据,sql,oracle11g,Sql,Oracle11g,我在查询每个计数数据和按类型分组的最大值时遇到问题 这是我的数据 type|category|ratio| 1001 1 10 1001 1 10 1001 1 8 1001 1 6 1002 2 5 1002 2 5 1002 2 15 1003 3 2 我有一个查询来计算所有这样的数据 select type, category, ra

我在查询每个计数数据和按类型分组的最大值时遇到问题

这是我的数据

type|category|ratio|
1001    1       10
1001    1       10
1001    1        8
1001    1        6
1002    2        5
1002    2        5
1002    2        15
1003    3        2
我有一个查询来计算所有这样的数据

select type, category, ratio, count(ratio) from age_ratio group by type, category, ratio
结果是

type|category|ratio|count
1001    1       10   2
1001    1        8   1
1001    1        6   1
1002    2        5   2
1002    2        15  1
1003    3        2   1
然后我想通过类型、类别和比率显示数据的最大(计数)组,如下所示:

type|category|ratio|count
1001    1       10   2
1002    2        5   2
1003    3        2   1
select r.type, r.category, r.ratio, 
max(r.num) as jum
from (select type, category, ratio, count(ratio) as num from age_ratio 
group by type, cat, ratio) r inner join ratio_age ra on
ra.type=r.type and ra.category=r.category and r.ratio=ra.ratio
group by r.type, r.category, r.ratio 
我的假设是这样的:

type|category|ratio|count
1001    1       10   2
1002    2        5   2
1003    3        2   1
select r.type, r.category, r.ratio, 
max(r.num) as jum
from (select type, category, ratio, count(ratio) as num from age_ratio 
group by type, cat, ratio) r inner join ratio_age ra on
ra.type=r.type and ra.category=r.category and r.ratio=ra.ratio
group by r.type, r.category, r.ratio 
使用
行编号()