How to retrieve a second highest salary from a table?
Note:Suppose salaries are in duplicate values
eg:
Name Sal
Malli 60000
Pandi 60000
Rudra 45000
Ravi 45000
Answer Posted / shriram
You can also do it by the following query ..
select * from (select name,salary,rank() over(order by
salary desc as r) from employee) where r = 2;
The above query returns the 2nd highest salary from the table.
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
What is primary key in db?
Does google use sql?
Why is %isopen always false for an implicit cursor?
explain normalization concept? : Sql dba
What is a subquery in sql?
how to use like conditions? : Sql dba
Explain architecture of sql server notification services?
How do I know if I have sql express or standard?
what is the difference between undefined value and null value? : Sql dba
Can we insert in view in sql?
write an sql query to find names of employee start with 'a'? : Sql dba
What does count (*) mean in sql?
how is exception handling handled in mysql? : Sql dba
What is constant in pl sql?
How does postgresql compare to mysql?