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

Answer Posted / anupam274

use AdventureWorks

select * from HumanResources.EmployeePayHistory e where
2 = (select count(distinct Rate) from
HumanResources.EmployeePayHistory where e.Rate<=Rate)

select * from HumanResources.EmployeePayHistory e where
4 >(select count(distinct Rate) from
HumanResources.EmployeePayHistory where e.Rate<=Rate)

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between ms sql and mysql?

479


What are %type and %rowtype for?

621


What are the differences between in and exists clause?

573


What is a primary key called that is made up of more than one field?

801


how to use myisamchk to check or repair myisam tables? : Sql dba

510






What is sqlite used for?

533


What is the function that is used to transfer a pl/sql table log to a database table?

557


State some properties of relational databases?

586


What operating systems are supported by oracle sql developer?

525


What are system versioned tables?

553


What are the two types of cursors in pl sql?

543


What is view explain with example?

523


What is the use of desc in sql?

496


What is a data definition language?

560


Which join condition can be specified using on clause?

517