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

Is postgresql a server?

736


What is difference between cursor and trigger?

761


What is the example of procedure?

678


What are the different type of joins in sql?

722


Which function is used to return remainder in a division operator in sql?

786






column A column b | output 10 7 | 10 5 8 | 8 7 -9 | 7 3 5 | 5 0 6 | 6 Write a sql query to print such output.

6593


What is sql architecture?

747


Which is faster union or join?

702


what is the difference between myisam static and myisam dynamic? : Sql dba

769


How can use stored procedures in sql?

773


Is pl sql better than sql?

719


What is a variable in sql?

725


What is pl/sql table? Why it is used?

738


how to get a list of columns in an existing table? : Sql dba

710


What is cte?

740