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

How do I find duplicates in the same column?

525


Mention what does plv msg allows you to do?

662


Is postgresql a server?

569


What are the different types of dbms?

543


Which language is used in sql?

514






What is a function in oracle pl sql?

531


What is a sql instance vs database?

568


Explain the insert into statements in sql?

559


in oracle 10g sw after compiling procedure how to pass parameter values ,if we (v_empid out number)how to give empid after successful compilation program.This site exact suitable for 10g with respect to question & answer same format , im trying sql browser & sql command prompt using exec procedure name & respective parameters.

1636


Is subquery faster than join?

564


Why do we use sql constraints?

650


Which certification is best for sql?

530


What is mdf ldf and ndf?

553


Is sql a backend language?

612


what are the 'mysql' command line options? : Sql dba

547