日期:2014-05-17 浏览次数:20808 次
with t as( select 'A' tid,1 flg from dual union all select 'A',2 from dual union all select 'A',3 from dual union all select 'B',1 from dual union all select 'C',1 from dual union all select 'C',2 from dual union all select 'C',2 from dual ) select tid, flg, count(1) c from t t1 where not exists (select 1 from t t2 where t1.tid = t2.tid and t2.flg > t1.flg) group by tid, flg order by tid TID FLG C --- ---------- ---------- A 3 1 B 1 1 C 2 2