Oracle 查询出现最多次的列
方法1.
select *
from exam_audit ea
where (ea.exam_id, ea.type) =
(select t1.exam_id, t1.type
from (select t.exam_id, t.type, count(1) as cnt
from exam_audit t
group by t.exam_id, t.type
order by cnt desc) t1
where rownum = 1);
方法2.
select max(exam_id || '===' || type) keep(dense_rank first order by cnt desc) xxx
from (select exam_id, type, count(*) as cnt
from exam_audit
group by exam_id, type);