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 see the table columns used in an index?
Is it possible to set second Primary Key Constraint in a table in Oracle Database ?
How to delete all rows a table in oracle?
How to use regular expression in pattern match conditions in oracle?
How can we view last record added to a table?
how can db_files > maxdatafiles since db_files is for instance and the later is for database
How to shutdown your 10g xe server from command line?
How to return top 5 rows in oracle?
What is the implicit cursor in oracle?
How a database is related to tablespaces?
Can we insert data in view oracle?
How can windows applications connect to oracle servers?
Explain oracle’s server parameter file.
How to load data through external tables?
Whats the benefit of dbms_stats over analyze?