how to find nth highest salary

Answer Posted / p rem satyam

This is perfect
...............................

select * from emp e1 where (N-1)=( select
count(distinct(e2.sal) from emp e2 where e2.sal > e1.sal)

where N is level of sal. suppose you want 3rd higest sal then
in place u write 3 i.e write (3-1).

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to list all objects in a given schema?

562


How to convert a numeric expression from one data type to another?

503


Why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it?

493


What does REVERT do in SQL Server 2005?

560


What command do we use to rename a database?

615






What are the 2 types of classifications of constraints in the sql server?

586


How to create an identity column?

638


What is difference between standardization and normalization?

532


What is outer join in sql server joins?

596


Explain what is row_number function?

561


Define msdb database?

598


What is the main difference between ‘between’ and ‘in’ condition operators?

587


Mention the differences between sql server and mysql.

511


What is the user of Primary key?

579


Explain view in sql server?

621