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
What happens if the update subquery returns multiple rows?
What are named parameters?
How to speed up webrick?
how to join query for one source type is oracle another source type is sql server ?
In AP we done Customizations for Late Payments Charges. For Reporting Purpose What are the Documents Prepared for Customer Understanding??
How to add a new column to an existing table in oracle?
How to insert a record into a table?
what is a Nested Loop join?
State the difference between a primary key and foreign key?
How many types of database triggers exist?
What do you mean by merge in oracle?
Which environment variables are absolutely critical in order to run the OUI?
How to create a new view in oracle?
How would you change old and new values in an insert, delete and update triggers?
Difference between inner join vs where ?