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 is a with(nolock)?

761


What are data driven subscriptions?

95


What are the pros and cons of putting a scalar function in a queries select list or in the where clause?

964


How to recover from sql injection? : sql server security

715


What is lock escalation? : sql server database administration

818


How many clustered indexes can be created on a table? I create a separate index on each column of a table. what are the advantages and disadvantages of this approach?

865


what protocol both networks use? : Sql server database administration

727


How can sql server instances be hidden?

699


How do I change my passwords (database, LDAP, and so on) without causing an outage?

794


What is BCP? When does it used in sql server 2012?

774


What does nvl stand for?

723


What are trace files?

715


Explain few examples of RDBMS?

778


What is the sql case statement used for?

763


how we use window authentication connection with sql server.?

822