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 define an oracle sub procedure?
what is the need of indexing topic in oracle? where do we use in a Java project? any other option other than using this to get the same result where we use indexing ?
State the difference along with examples between Oracle 9i, Oracle 10g and Oracle 11i.
What is oracle database 10g express edition?
What is user managed backup in Oracle?
What are the uses of linked server and explain it in detail?
What's dateware house and what's clustor with practicle example
How to run queries on external tables?
List out the difference between commit, rollback, and savepoint?
In what script is snap$ created? In what script is the scott/tiger schema created?
Explain oracle instance.
How to convert times to characters in oracle?
How to start an oracle instance?
How to create a table index in oracle?
How to use in conditions in oracle?