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 pl sql collection?
Enlist the characteristics of pl/sql?
What is partition in sql query?
What is a primary key sql?
Can we use two order by clause in query?
What are pl sql data types?
Can %notfound return null after a fetch?
What is sqlerrm?
What is sql injection vulnerability?
Explain the commit statement.
what is a constraint? : Sql dba
Can we use having without group by in sql?
what is cross join? : Sql dba
what is the difference between where clause and having clause? : Sql dba
Is sql database free?