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' along with
'order by' (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 ? | 3 Yes | 9 No |
Post New Answer View All Answers
What is the difference between a fill factor of 100 and 0?
What will be the maximum number of index per table?
Describe how to use the linked server?
How to retrieve field values using mssql_result()?
How to enable/disable indexes?
How to convert numeric expression data types using the cast() function?
If no size is defined while creating the database, what size will the database have?
role of sql sever 2005 in database rather than any other database
How to create new tables with "select ... Into" statements in ms sql server?
Give an example of SQL injection attack ?
How to create a new schema in a database?
What are the dmvs? : sql server database administration
How many tables can be joined in SQL Server?
What is sqlservr.exe - process - sql server (sqlex?press)?
Why use update_statistics command in sql server?