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
Explain what are magic tables in sql server?
In what sequence sql statement is processed?
what are user defined datatypes and when you should go for them? : Sql server database administration
How to convert character strings into numeric values?
How many triggers are possible per table?
What are the properties of sub-query?
You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?
Explain about SQLOS?
What is a scheduled job or what is a scheduled task?
Can a stored procedure call itself or recursive stored procedure? How much level sp nesting is possible?
Is it ok to shrink transaction log?
If you want to send some data from access database to sql server database. What are different component of ssis will you use?
How can you list all the table constraints in a database?
what is the difference between delete table and truncate table commands? : Sql server database administration
Suppose i have a table that contains 5 columns like col1,col2...colm5.I want to import only two column through BCP utility.How to do same through BCP in sybase.