Query to get max and second max in oracle in one query ?
Answer Posted / kevin sharpless
-- This query wiil return any number of the n items by
using the max/decode statements
select max(decode(rnum,1,salary,null)) max1
,max(decode(rnum,2,salary,null)) max2
from (
select 1 grp_col
,salary
,row_number() over (order by salary asc) rnum
from (
select distinct salary
from emp
)
)
group by grp_col
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How to empty your oracle recycle bin?
What are the differences between blob and clob in oracle?
Explain the use of grant option in exp command.
How to retrieve values from data fields in record variables?
What is open database communication (odbc) in oracle?
Explain self joins in oracle?
How to set a transaction to be read only in oracle?
How to list all user accounts in oracle?
Hi friends can u send the oracle 9i full version download link?????????????? please reply ?
How would you configure your networking files to connect to a database by the name of DSS which resides in domain icallinc.com?
How to write text literals in oracle?
How to create a stored program unit?
How to assign a table row to a record variable?
What is a trigger and what are its types in oracle?
Can you assign multiple query result rows to a variable?