how to find nth highest salary

Answer Posted / bharath

select distinct(sal) from emp a where 3 = (select
count(distinct(sal)) from emp b where a.sal<= b.sal)

replace 3 by 2 for second highest...

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are four major operators that can be used to combine conditions on a where clause?

587


Can the query output be sorted by multiple columns in ms sql server?

549


What is difference between inner join and join?

534


What is the guest user account in sql server? What login is it mapped to it? : sql server security

577


What are the tool windows in sql server management studio? : sql server management studio

610






How to assign null values to variables or columns?

541


How do you create type- insensitive operator?

565


How do I create an extended event in sql server?

480


How to use linked server?

581


What is difference between count (*) and count 1?

509


How to connect ms access to sql servers through odbc?

539


What is the cpu pressure?

557


What is the difference between dropping a database and taking a database offline?

692


How to automatically create a log when an exception is being received into SQL Server?

729


Do you know how to store and query spatial data?

596