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 execute a stored procedure in oracle?
Explain the use of Merge statement in oracle 11g
What is the difference between a user and a schema in oracle?
How to select an oracle system id (sid)?
How to find out what oracle odbc drivers are installed?
What is java oracle used for?
State and explain about oracle instance?
What are the most common interview questions on ETL Testing for experience?
What is index in Oracle?
is there a tool to trace queries, like profiler for sql server?
What is a trace file and how is it created in oracle?
What are the restrictions in a oracle read only transaction?
How to define a variable of a specific record type?
How to resolve name conflicts between variables and columns?
What language does oracle use?