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
How we can compare two database data?
what is sql server? : Sql server database administration
what do you understand by change data capture?
What is the sql case statement used for?
What is report subscription?
How to find the list of fixed hard drive and free space on server?
What is the partitioning method?
What happens if the update subquery returns no rows in ms sql server?
How do I start sql server 2017?
How can I check if a view exists in a sql server database?
Data is not being delivered to subscribers, what can be the possible reasons? : sql server replication
How exceptions can be handled in sql server programming?
What is difference between stored procedure and user defined function?
Can you name some of the dml commands in sql?
What are the rules to use the rowguidcol property to define a globally unique identifier column?