August 17, 2012 at 4:48 am
raghuldrag (8/17/2012)
friends ,select top 2*
from empy order by cast(sal as int)desc
in these query has given first two max values, now i need the ouput while i am giving the position =3 means third max sal has to display.....i.e 2500
Properly asked question contains over 50% of answer.
The way you present yours one, makes very hard to understand exactly what do you want.
If you want single 3rd largest record from your datasetup on SQL2000 you can do:
select top 1 *
from (
select top 3 *
from #emp
order by cast(sal as int)
desc
) a
order by cast(sal as int)
I would suggest you to read the article under the link at the bottom of my signature. If you follow its tips, you would get appropriate answer to your question in a first reply...
August 17, 2012 at 5:16 am
raghuldrag (8/17/2012)
ya its workin..... suppose i need the particular top 3rd postion of max salary means how to modify
Declare @position Varchar(30)
Set @position = 'sales'
Select Top 1 * From
(
Select top 3 * From Ex Where Job = @position
Order By sal DESC
) As a
Order By sal DESC
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply