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


Please Help Members By Posting Answers For Below Questions

What is native sql query?

548


How do you select unique values in sql?

500


Can we commit inside a trigger?

547


Why do we use partitions in sql?

545


how to select first 5 records from a table? : Sql dba

509






What is sql*plus?

567


What programs use sql?

524


How do I count duplicates in sql?

545


What is $$ in sql?

553


What is composite primary key in sql?

520


How do you delete a table?

537


What is pl sql code?

586


What are transaction and its controls?

559


Explain raise_application_error.

643


discuss about myisam index statistics collection. : Sql dba

526