4 个解决方案
#1
或者是统计某一列中出现次数最多的10条数据。
#2
select 字段 from (select 字段,count(字段) ,rownum rn 重复数 from 表 group by 字段 order by 重复数) where rn<=10
#3
用到group by,及having
select 字段,count(字段) ,rownum rn 重复数 from 表 group by 字段
having count(字段)<=10
order by 重复数
select 字段,count(字段) ,rownum rn 重复数 from 表 group by 字段
having count(字段)<=10
order by 重复数
#4
select 字段 from (select 字段,count(字段) ,row_number()over(order by count(1) desc) rn 重复数 from 表 group by 字段) where rn<=10
#1
或者是统计某一列中出现次数最多的10条数据。
#2
select 字段 from (select 字段,count(字段) ,rownum rn 重复数 from 表 group by 字段 order by 重复数) where rn<=10
#3
用到group by,及having
select 字段,count(字段) ,rownum rn 重复数 from 表 group by 字段
having count(字段)<=10
order by 重复数
select 字段,count(字段) ,rownum rn 重复数 from 表 group by 字段
having count(字段)<=10
order by 重复数
#4
select 字段 from (select 字段,count(字段) ,row_number()over(order by count(1) desc) rn 重复数 from 表 group by 字段) where rn<=10