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 2012 Forums
 Transact-SQL (2012)
 Case SQL question

Author  Topic 

SQLBoy14
Yak Posting Veteran

70 Posts

Posted - 2015-01-21 : 12:23:24
How do I case sql statement per below condition?

If field1 = 2 and field2=D replace the Field3 with 253

Field1 Field2 Field3
1 A 454
2 B 253
3 C 552
2 D 225

Thank you

SQLBoy

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-01-21 : 12:33:55
case when field1=2 and field2='D' then 253 else Field3 end

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SQLBoy14
Yak Posting Veteran

70 Posts

Posted - 2015-02-01 : 09:26:32
Thank you tkizer

SQLBoy
Go to Top of Page
   

- Advertisement -