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
Are there any preferred steps that need to be taken care of before starting the installation of sql server 2000?
What are the difference between primary keys and foreign keys?
What is a dbms wizard?
What is isolation levels?
Explain steps of normalization?
What are diverse clauses that form a part of sql?
What do you mean by tablesample?
When I delete any data from a table, does the sql server reduce the size of that table?
Tell me the use of keyword with encryption. Create a store procedure with encryption?
How to rename an existing column with the "sp_rename" stored procedure in ms sql server?
Does sql server 2000 full-text search support clustering?
Can we make the the chages By Using the Sql if u know any function or process please inform me Actuall result: BRK1 Break 1 Part 1 00:01:00:00 60 BRK1 Break 1 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 BRK2 Break 2 Part 2 00:01:00:00 60 BRK2 Break 2 Part 3 00:01:00:00 60 BRK3 Break 3 Part 1 00:01:00:00 60 BRK3 Break 3 Part 2 00:01:00:00 60 Desired O/P: BRK1 Break 1 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 Part 3 00:01:00:00 60
Which is better statement or preparedstatement?
Why use sub query in sql server and list out types of sub queries?
How to create a view using data from another view?