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 / sreeharibabu

SELECT id
FROM (select salary2.*, rownum rnum from
(select * from test ORDER BY id DESC) salary2
where rownum <=2 )
WHERE rnum >= 2;

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does a primary key have to be a number?

522


what are the advantages of sql ? : Sql dba

550


How do I tune a sql query?

514


how does a local variable is defined using t-sql? : Transact sql

546


What is primary key secondary key alternate key candidate key?

546






Why is pl sql used?

528


explain the difference between bool, tinyint and bit. : Sql dba

529


Why do we use procedures in sql?

550


what is a record in a database ? : Sql dba

568


What packages are available to pl/sql developers?

605


What is data manipulation language?

702


Is it possible to create the following trigger: before or after update trigger for each row?

722


Is json a nosql?

541


What is a sql*loader control file?

622


What is a heap in sql?

530