88问答网
所有问题
如何用oracle查询第二大的值,例如aaa 1,bbb 2,ccc 3要求列出bbb 2
其中1 2 3是count以后的值,所以最好可以使用max count指令,谢谢,求大神
举报该问题
其他回答
第1个回答 2012-05-17
select max(count) from 表 where count not in (select max(count) from 表)
这是sql server的语法,你换成oracle的就行了
第2个回答 2012-05-25
select * from (
select col1, count(1) , row_number() over(order by count(1) desc) row_num from dual
group by col1
) where row_number = 2
相似回答
大家正在搜
相关问题
sql查询 一个表 ID type 1 aaa 2 aaa ...
Oracle数据库怎么列出某一列第二大的值
oracle查询第二大数据问题
oracle数据库中将字符串'aaa,bbb,ccc'转为为...
oracle sql里有多个max时数据是怎么查的
oracle如何将aaa_bbb_ccc(为一列中的内容)进...
数据库查询一对多关系,只列出一条数据
oracle分组统计查询之后,获取数量最大的记录