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 | 2 No |
Post New Answer View All Answers
Is sql a scripting language?
Explain the update statement in sql
Can ddl statements be used in pl/sql?
Which command is used to delete a package?
What is sql query optimization?
Are left and right joins the same?
What does where 1 1 mean in sql?
What is the use of desc in sql?
What is the difference between view and stored procedure?
How do you update a sql procedure?
How delete all records from table in sql?
What is pragma in pl sql?
What is the difference between alter trigger and drop trigger statements?
what are the types of join and explain each? : Sql dba
What is the difference between a procedure and a function?