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
How do you declare a user-defined exception?
How do you create an update query?
how to escape special characters in sql statements? : Sql dba
How do I save a sql query?
What are the different schemas objects that can be created using pl/sql?
How do you rename a table in sql?
What has stored procedures in sql and how we can use it?
how can we submit a form without a submit button? : Sql dba
Why procedure is used in sql?
what is bcp? When is it used?
How many row comparison operators are used while working with a subquery?
What are the different datatypes available in PL/SQL?
How do you remove duplicate records from a table?
What is AUTH_ID and AUTH_USER in pl/sql ?
what is self-join? : Sql dba