oracle查询取第二名的值。
查询语句如下:
select ADD_SHI , sum(pro_zijin) as hzijin5 from ts_zijin where PRO_YEAr = 2013 group by ADD_SHI order by hzijin5 desc ;
查询结果为:
使用 rank 查询的写法如下:
select * from ( select a.*, rank() over(order by hzijin5 desc ) as lev
from ( select ADD_SHI , sum(pro_zijin) as hzijin5 from ts_zijin
where PRO_YEAr = 2013 group by ADD_SHI order by hzijin5
) a )where lev = 2 ;
查询结果如下: