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 2008 Forums
 Transact-SQL (2008)
 if statement question

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2013-02-08 : 10:52:16
hello there.

i want to create a multi if statement with and conditions.

see my query below.



select client_ref, if [2013] > 0 and [2012] = 0 and [2011] = 0 then 'New'

from Match_Count_By_Year

im wondering if i could use a case, but not sure how to with multi and's conditions.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-02-08 : 10:56:25
[code]
select
client_ref,
CASE
WHEN [2013] > 0 and [2012] = 0 and [2011] = 0 then 'New'
ELSE 'notNew'
END as ColumnName
from...
[/code]


Too old to Rock'n'Roll too young to die.
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2013-02-08 : 10:58:37
ive just sussed it out, ive done exactly what you done.

thank you very much.
Go to Top of Page
   

- Advertisement -