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
Is sql better than excel?
Can we create clustered index without primary key?
Is oracle sql free?
What are functions in sql?
what are the different type of normalization? : Sql dba
What is sql rowcount?
What is procedure and function in sql?
What is transaction control language (tcl)?
What is sql comments?
what is an alias command? : Sql dba
Is sql a backend language?
differentiate between float and double. : Sql dba
What is dbo in sql?
How do I truncate a sql log file?
What is auto increment feature in sql?