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
Can we write insert statement in function in oracle?
Explain the difference between a procedure and a function?
candidate key is subset of super key but not vice-verse explain
What is recovery manager(rman) backup in Oracle?
Explain what are synonyms used for?
What is a tns service name?
How data locks are respected in oracle?
How to use like conditions in oracle?
Please explain oracle left join with an example?
Explain what are the different type of segments?
What do you mean by merge in oracle?
How to specify default values in insert statement using oracle?
How to open a cursor variable?
What are the roles of dba?
What is bulk copy or bcp in oracle?