首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Oracle 查询出现至多次的列

2013-07-11 
Oracle 查询出现最多次的列方法1.select *from exam_audit ea where (ea.exam_id, ea.type) (select t1.e

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);

热点排行