September 7, 2007 at 8:14 am
Thanks alot, that works, but it fills every row with that statement, which isn't exactly what i want. I'll explain...
I want it only to mark the person who has requested the query as the marker. I have tried moving the cast statement to inside the CTE, but because that where clause is date based, it still fills every row with the requesters name.
Any ideas, otherwise I will just stick to doing that with ASP.
September 7, 2007 at 9:25 am
So you mean that requester is blanc if it is note equal to alias ?
;with cteMPVAliasByRank (Ranking, Alias, Country, Yearmonth, PrizeAmount)
as (select ROW_NUMBER() over (order by PrizeAmount desc) , Alias, Country, Yearmonth, PrizeAmount
from #tblMPVLeaderBoard where Yearmonth = @CurrentMonth )
SELECT M.*, cast(case Alias when @PlayerAlias then Alias else ' ' end as varchar(50) ) as Requester
FROM cteMPVAliasByRank M
INNER JOIN cteMPVAliasByRank PA
ON PA.Alias = @PlayerAlias
AND M.Ranking BETWEEN PA.Ranking - 3 AND PA.Ranking + 3 ;
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data and code to get the best help
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 10, 2007 at 12:37 am
that is exactly what I was trying to do... Thanks for all the help. Just one thing though, you need to prefix the cast columns with M. otherwise it gives a "ambiguous column" error.
;with cteMPVAliasByRank (Ranking, Alias, Country, Yearmonth, PrizeAmount)
as (select ROW_NUMBER() over (order by PrizeAmount desc) , Alias, Country, Yearmonth, PrizeAmount
from #tblMPVLeaderBoard where Yearmonth = @CurrentMonth )
SELECT M.*, cast(case M.Alias when @PlayerAlias then M.Alias else ' ' end as varchar(50) ) as Requester
FROM cteMPVAliasByRank M
INNER JOIN cteMPVAliasByRank PA
ON PA.Alias = @PlayerAlias
AND M.Ranking BETWEEN PA.Ranking - 3 AND PA.Ranking + 3 ;
September 10, 2007 at 12:58 am
indeed.
Little things you forget when you quickly try to do a last thing of the day
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data and code to get the best help
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 10, 2007 at 1:00 am
Hehe... thanks for all your help, the slimming down of this query has really sped up the results. Now all that is left is to test it in a live environment, with more than one query being called at a time...
Thanks again
Viewing 5 posts - 16 through 20 (of 20 total)
You must be logged in to reply to this topic. Login to reply