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
What is native sql query?
How do you select unique values in sql?
Can we commit inside a trigger?
Why do we use partitions in sql?
how to select first 5 records from a table? : Sql dba
What is sql*plus?
What programs use sql?
How do I count duplicates in sql?
What is $$ in sql?
What is composite primary key in sql?
How do you delete a table?
What is pl sql code?
What are transaction and its controls?
Explain raise_application_error.
discuss about myisam index statistics collection. : Sql dba