how to find nth highest salary
Answer Posted / nandkumar karlekar
Take this script and try u will get nth salary as you wish
create Table EmpTest
(
ID bigint,
Sal bigint
)
go
insert into emptest
values
(1,100)
insert into emptest
values
(2,200)
insert into emptest
values
(3,300)
insert into emptest
values
(4,400)
insert into emptest
values
(5,500)
insert into emptest
values
(6,600)
go
DECLARE @n bigint
--specify your nth salary
SET @n=3
select top 1 * from Emptest
where @n <= (select Count(*) from Emptest EE where EE.sal
>Emptest.sal)
order by sal desc
Is This Answer Correct ? | 0 Yes | 3 No |
Post New Answer View All Answers
Tell me what are the advantages of using stored procedures?
Do you know how to send email from database?
You want to be sure that queries in a database always execute at the maximum possible speed. To achieve this goal you have created various indexes on tables which other statement will keep the database in good condition?
What are partitioned views and distributed partitioned views?
Explain the etl (extraction, transformation, and loading)?
What are the parts of a function?
How do I find information about the install locations for the various instances running on a computer?
how can you attach more than 20 ldf files in sql server
Define model database?
What is user-defined function?
How to run sql server 2005 books online on your local system?
Why and when do stored procedure recompile?
Why use view instead of a table?
Do you know what is openxml in sql server?
What is logshipping and its purpose?