case when col1 is null then 0 else col1 end as COLUMNX
SQL VIEW - add column based on value of another
-
14-10-2022 - |
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!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow