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 put more than 1000 values into an oracle in clause?
If any one has information regarding interview of NIC (National Informatics Centre),it would be of great help...
hi friends i completed b.com 2004.i have 3y accounting exp. in manufacturing company.now i have completed oracle finance.pls suggest me how will get job in oracle.can i get job in oracle.
What is the sid in oracle?
Point the difference between translate and replace?
Explain a private synonyms?
master table and child table performances and comparisons in Oracle ?
What is save point in oracle database?
how can we store any pdf file in oracle
How to insert a record into a table?
How would you change old and new values in an insert, delete and update triggers?
Why do you create or replace procedures rather that drop and recreate.
what is the difference between restoring and recovering?
What is the purpose of save points in oracle database?
Can you tell me how to add new column in existing views?how?How is possible?