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 are the built-in functions used for sending Parameters to forms ?
Compare and contrast between sql and sql server and explain its various functions?
What is the difference between substr & instr functions?
How to run create database statement?
Respected sir, Please send me technical questions related to oracle apps..
State the difference along with examples between Oracle 9i, Oracle 10g and Oracle 11i.
Why is oracle used?
Is a rollback possible to any savepoint?
What is the data type of dual table?
How to write text literals in oracle?
Difference between oracle's plus (+) notation and ansi join notation?
What is coalesce function?
What are the differences between char and nchar in oracle?
Can you have more than one content canvas view attached with a window ?
How to empty your oracle recycle bin?