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
Can we use where clause with group by?
Explain having clause?
How to name query output columns in ms sql server?
What is difference between rollback immediate and with no_wait during alter database?
What is relationship? What number of sorts of relationship are there?
What are the types of joins in sql?
What is the difference between varchar and varchar(max) datatypes?
What are cursors? Explain the different types of cursors Enlist a few disadvantages of cursors.
What does <> symbol mean?
Name few endpoints exposed by ssrs 2012?
What is the difference between migration and upgradation in sql server?
What is checkpoint in sql server?
How to convert character strings into numeric values?
How do you test your database? : sql server database administration
How global temporary tables are represented and its scope?