how to find nth highest salary
Answer Posted / sysdomain
'top' will fetch only top most : ie top 5 means it will
fetch first 5 rec. After fetching rec only 'order by' is
done ie sorting is done after fetching. therefore using
'top' and 'order by' alone wont get max or min value. for
that we have to use 'distinct' before 'top' (which will sort
the records before fetching).
select top 1 salary from employee where salary in (select
distinct
top n salary from employee order by salary desc)
Is This Answer Correct ? | 7 Yes | 16 No |
Post New Answer View All Answers
What are the advantages of user-defined functions over stored procedures in sql server?
Can you explain what are the restrictions applicable while creating views? : SQL Server Architecture
What is normalization according to you and explain its different levels?
What is the synonym of join?
What is difference between joins and subqueries?
How to download and install sql server 2005 books online?
How to enforce security in sql server? : sql server security
What are the differences between left join and inner join in sql server?
What does top operator do?
What are views in ms sql server?
Can sql servers linked to other servers?
Is truncate a dml command?
Explain what you mean by 3 tier architecture.
What is check constraint in sql server?
Recommend an approach to ensuring that all changes in the remote databases synchronize with the SQL Azure database?