Query to get max and second max in oracle in one query ?
Answer Posted / lokanath
select * from emp a where 2 > (select count(distinct sal)
from emp b where b.sal > a.sal)
or else use Top Window functions (or) Analatical functions
select * from
(
select empno,ename,sal,rank() over (order by sal desc)
test from emp
)
where test <= 2
| Is This Answer Correct ? | 12 Yes | 4 No |
Post New Answer View All Answers
Explain the use of rows option in exp command.
can u send the sql dumps to sivakumarr1987@gmail.com plz help me
How to add a new column to an existing table in oracle?
Difference between the “verify” and “feedback” command?
What is instant client oracle?
How to connect asp pages to oracle servers?
What are the system predefined user roles?
Why should I use oracle database?
Explain oracle’s server parameter file.
What is the use of oracle?
How to pass parameters to procedures in oracle?
How to bring a tablespace offline?
How to view existing locks on the database?
What is an oracle and why it is used?
What is tns name?