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
How to view the error log for any specific instance? : sql server database administration
What are the advantages of stored procedure in sql server?
What are indexes in sql?
How many triggers are possible per table?
What is BCP? When does it used in sql server 2012?
Working with TLogs
can an automatic recovery be initiated by a user? : Sql server administration
What is multilevel indexing?
Can we write trigger for view?
Explain sub-query?
Explain what are the different index configurations a table can have?
What are the pre-defined functions in the sql server?
What is difference between views and tables?
Why do you need a sql server?
What functions can a view be used to performed?