Query to get max and second max in oracle in one query ?
Answer Posted / sunil
select sal from (select dense_rank() over(order by sal) rank
from emp) where rank in(1,2);
In above query you will get both highest and second highest
salary details even there are more people who are getting
highest and second highest salary.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can group functions be mixed with non-group selection fields?
How many types of tables supported by oracle?
What is the exact use of Collections?
how can we store any pdf file in oracle
How to use "startup" command to start default instance?
Is there a combination of "like" and "in" in sql?
What privilege is needed for a user to create indexes in oracle?
Explain what are the different type of segments?
What is catalog in Oracle?
Can we write dml statement in function in oracle?
Can you assign multiple query result rows to a variable?
What do you mean by merge in oracle and how can we merge two tables?
How to see the table columns used in an index?
Explain the characteristics of oracle dba?
What are set operators?