Question

I would like to create a view that selects ALL columns in a table, then creates/adds an additional "columnX" based on the value of another column in that same table.

For example if [column1] IS NULL, I would like [columnX] = 0 (zero) and if [column1] IS NOT NULL, I would like [columnX] = [column1]

I think this should be simple, but I cannot seem to find the solution. Can anyone please help? Thanks!

Était-ce utile?

La solution

case when col1 is null then 0 else col1 end as COLUMNX

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top