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


Please Help Members By Posting Answers For Below Questions

How to display employee records who gets more salary than the average salary in the department?

599


Can you drop an index associated with a unique or primary key constraint?

587


Please explain me all types of Data models. Also give me the details if each model can have other name.for example:schematic data model is also known as conceptual data model and entity relation data model.

1869


Is it possible to center an object horizontally in a repeating frame that has a variable horizontal size ?

1882


What are the attributes of cursor?

591






What is the difference between Delete, Truncate and Drop in Oracle?

606


Explain index?

755


What is a relational database management system?

679


Iam learning oracle developer 2000.. can anyone give me then tutorials sites or PDF related to developer 2000 please send me the details @ mak2786@gmail.com thanks Arun

1666


How does Oracle guarantee data integrity of data changes?

1938


Explain the use of Merge statement in oracle 11g

598


Does oracle partitioning improve performance?

552


Point the difference between translate and replace?

577


How to write a query with a left outer join in oracle?

607


What is a trigger and what are its types in oracle?

535