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

What operating systems are supported by oracle sql developer?

513


What are sql functions? Describe the different types of sql functions?

548


What is pl sql and why it is used for?

565


what is oltp (online transaction processing)? : Sql dba

526


Is sql developer case sensitive?

510






Why schema is used in sql?

508


Why query optimization is needed?

508


Can we use ddl statements in stored procedure?

691


How do you optimize a stored procedure query?

561


What is snowflake sql?

571


Why cross join is used?

622


what is the difference between nested subquery and correlated subquery?

543


what is top in tsql? : Transact sql

533


What are secondary keys?

552


What are tables and fields?

578