Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Problem in CASE WHEN

Author  Topic 

ganeshkumar08
Posting Yak Master

187 Posts

Posted - 2008-05-21 : 00:29:24
This is my table structure.
---------------------------------------------------------------------------
MatchID SegmentID Time Event Player1 Player1ClubID Player2 Player2ClubID
--------------------------------------------------------------------------
1 0 1 1 20 88 -1 -1
--------------------------------------------------------------------------

I need to select Player1 or Player2, My criteria is
If Player1=-1
Then Player2 -- selected
Else Player2=-1
Then Player1 -- Selected

How to do this
Thanks
Ganesh Kumar



Solutions are easy. Understanding the problem, now, that's the hard part

ganeshkumar08
Posting Yak Master

187 Posts

Posted - 2008-05-21 : 01:04:33
hello guys,
I got it..
select distinct player = ( case when ISNULL(Player1,-1) = -1
then Player2
when ISNULL(Player2,-1) = -1 then Player1
end )
from trendevents where matchid=1

Thanks
Ganesh
Go to Top of Page
   

- Advertisement -