Write a query to get 2nd maximum salary in an employee table ?

Answer Posted / ashish jain

select Salary from
(
select salary,ROW_NUMBER() over (order by salary desc) as rownum from Emp group by salary) temp
where rownum=2

Note :It can be used to get any highest salary, just use where rownum=nth salary

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an inner join sql?

549


what is a constraint? Tell me about its various levels. : Sql dba

564


How to load data with sql*loader?

552


Can there be more than one function with a similar name in a pl/sql block?

551


What is the use of %rowtype?

537






Explain exception handling in pl/sql?

535


How many types of indexes are there in sql?

537


What is rank dense_rank and partition in sql?

541


What is union, minus and interact commands?

750


Why procedure is used in sql?

537


Sql technical questions

779


Why do we use set serveroutput on?

520


How many types of privileges are available in sql?

739


What is difference between ms sql and mysql?

479


How to return multiple rows from the stored procedure?

524