Query to get max and second max in oracle in one query ?

Answer Posted / rohit

The below query will provide the max and second max in
oracle in one query

select * from emp e
where 0 = (select count(sal) from emp
where e.sal < sal)
or 1 = (select count(sal) from emp
where e.sal < sal);

Is This Answer Correct ?    17 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between cartesian join and cross join?

540


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.

1961


How to list all user accounts in oracle?

608


Explain drop constraint oracle?

589


What is merge in oracle?

558






Explain compound trigger in oracle?

546


Can you assign multiple query result rows to a variable?

546


What are the different pseudo commands? Explain in general?

539


How to find the duplicate rows count from employees table in oracle?

543


How to use an explicit cursor without open statements?

612


WHAT IS ecc 6.0

1660


How does propagation differ between Advanced Replication and Snapshot Replication (read-only)?

1827


What would you do with an in-doubt distributed transaction?

1466


How to convert characters to numbers in oracle?

594


What is the difference between online and offline backups?

560