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.
Author |
Topic |
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2012-12-10 : 05:13:28
|
Hey Guys This is really basic question, but i am really struggling I believe i need a case when statement but not sure how to go around it.In the [Omnipay_Account]column there is only ever two outcomesEither Null Or a number For eg FDMSAccountNo Omnipay_Account 878000000884 NULL878000001882 NULL878000002880 NULL878000003888 NULL878000000884 000001878000001882 000012878000002880 000013878000003888 000014I want to create a separate coloumn to say, if the [Omnipay_Account] is null then produce a 0, if it has a number to produce 1. FDMSAccountNo Omnipay_Account New column 878000000884 NULL 0 878000001882 NULL 0 878000002880 NULL 0 878000003888 NULL 0878000000884 000001 1878000001882 000012 1 878000002880 000013 1878000003888 000014 1This is my query so far SELECT [FDMSAccountNo],[Omnipay_Account] FROM [FDMS].[dbo].[Dim_Outlet] |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-12-10 : 05:27:03
|
SELECT [FDMSAccountNo],[Omnipay_Account], CASE WHEN [Omnipay_Account] IS NOT NULL THEN 1 ELSE 0 END [New Column]FROM [FDMS].[dbo].[Dim_Outlet]--Chandu |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-14 : 02:12:21
|
SIGN(COALESCE(Omnipay_Account,0)) AS newColumn------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|