SQL> select sal from emp e where 3=(select count(distinct sal) from emp where e.sal>=sal);
SAL
----
1100
SQL> SELECT A.ENAME,A.SAL FROM (SELECT ENAME,SAL,DENSE_RANK() OVER (ORDER BY SAL) RK FROM EMP) A WHERE RK=2;
ENAME SAL
---------- ----
JAMES 950
SAL
----
1100
SQL> SELECT A.ENAME,A.SAL FROM (SELECT ENAME,SAL,DENSE_RANK() OVER (ORDER BY SAL) RK FROM EMP) A WHERE RK=2;
ENAME SAL
---------- ----
JAMES 950
No comments:
Post a Comment