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
How to check database size in Oracle?
What is define in oracle?
Can multiple cursors being opened at the same time?
How do we get field details of a table?
How to recover a dropped table in oracle?
6. Display the client name and order date for all orders using the traditional method.
How to loop through a cursor variable?
how to handle exceptions in post production
What is the difference between hot backup and cold backup in oracle?
What is materialized view in Oracle?
Explain the use of compress option in exp command.
Which is faster join or subquery in oracle?
Why does for update in oracle 8 cause an ora-01002 error?
How to check your oracle database 10g xe installation?
How to pass a parameter to a cursor in oracle?