怎样获得oracle数据表中某个字段的第二个最大值
怎样获得数据表中某个字段的第二个最大值
SQL> select * from paul;
A B
---------- ----------
12 13
10 15 SQL> select * from paul;
A B
---------- ----------
12 13
10 15
11 10
13 15
SQL> select max(B) from paul where B<(select max(B) from paul);
MAX(B)
----------
13
SQL>
SQL> select max(b) from (
2 select b,dense_rank() over(order by b desc) m from paul)
3 where m>1;
MAX(B)
----------
13
select distinct b from
(
select b,dense_rank() over(order by a desc) m from paul
) t
where t.m=2;
11 10
13 15
SQL> select max(B) from paul where B<(select max(B) from paul);
MAX(B)
----------
13
SQL>
SQL> select max(b) from (
2 select b,dense_rank() over(order by b desc) m from paul)
3 where m>1;
MAX(B)
----------
13
select distinct b from
(
select b,dense_rank() over(order by a desc) m from paul
) t
where t.m=2;