Query to get max and second max in oracle in one query ?
Answer Posted / bhanu yadav
For Nth Max.
select distinct a.sal from emp a where &N= (select count
(distinct b.sal) from emp b where b.sal>=a.sal)
For Nth Min.
select distinct a.sal from emp a where &N= (select count
(distinct b.sal) from emp b where b.sal<=a.sal)
| Is This Answer Correct ? | 9 Yes | 6 No |
Post New Answer View All Answers
 How to use an oracle sequence generator in a mapping?
What is the difference between $oracle_base and $oracle_home?
How to find out what oracle odbc drivers are installed?
How to test null values?
How to check the oracle tns settings?
Explain an extent?
What are the general rules on data consistency?
what is normalisation?what are its uses?
How remove data files before opening a database?
How to do paging with oracle?
What is a snapshot in oracle database?
Explain a synonym?
What is connection pooling in oracle?
What is index-organized table in Oracle?
21. Using a set operator, display the client number of all clients who have ever placed an order and whose whose name does not contain the string Sm.