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 may join possible between (requisition with purchase order)
How do I decide when to use right joins/left joins or inner joins or how to determine which table is on which side?
What are the various oracle database objects?
How to define a data field as not null?
What are the numeric comparison operations?
What is the difference between the Oracle ODBC driver and a Microsoft ODBC (Open Database Connectivity) Driver?
How to invoke the data pump export utility?
What are the differences between number and binary_float in oracle?
What are the four Oracle system processes that must always be up and running for the database to be useable?
What are the predefined tablespaces in a database?
How to start a specific oracle instance?
Oracle
How to join two tables in a single query using oracle?
How to connect to a local oracle 10g xe server?
How a tablespace is related to data files?