Result of a CASE how to convert numeric to character using to_char
Posted on 2008-09-30
I have a table that the information is being exported out to be used by another vendor source. I need a new column included in the exported data named "NewSC". The value of NewSC should be the value of SVCCD in character form. SVCCD is numeric. And if SVCCD is null then NewSC needs to contain a '0' vlaue and not null.
I used a CASE to populate the NewSC. However the NewSC needs to be in character. How do I achieve this? I tried to use the to_char but I get an error.
I have practically zero SQL exposure so I'm not sure if it is syntax that is wrong or something entirely different.
The code below runs without error and gives the results requested except the values in the NewSC are numeric and they need to be character.
when ACTICDMF.SVCCD IS NULL
end as NewSC
FROM WAREHOUSE.ACTICDMF ACTICDMF
WHERE (ACTICDMF.CMHOSP = 067)
Thanks in advance for input and assistance.