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
What is the beast way to write CTE in SQL Server ?
1 01 101 01010
Explain what is public role in sql server?
How to get all stored procedures in sql server?
What is the difference between system objects and user objects?
Explain ranking functions?
Where sql server usernames and passwords are stored in a sql server?
Is INSTEAD OF trigger directly applicable to Table ?
What is the difference between update lock and exclusive lock?
How to rebuild master databse?
hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.
What are binary string data types in ms sql server?
How to use go command in "sqlcmd"?
How to use wildcard characters in like operations in ms sql server?
How do you improve the performance of a SQL Azure Database?