Reputation: 129
I am currently working on a data flow and have been given a specific requirement that i am trying to complete.
In my table I have a column which is partially NULL
due to a couple of reasons.
What I'm trying to do is write a case
expression within my select statement that has two conditions:
When NULL
use a different value from another column (which is pulled from another table using a join)
If the column is still NULL
(in both cases) then use a different value from another column in the table which will ensure the column is populated.
So basically, if it's NULL
do this, if its still NULL
, then do this which will mean my column is populated as i intend.
I've been playing around but have been unable to produce the required result. Is this something that can be achieved using a CASE
expression ?
Any help/advice would be appreciated.
Thanks.
Upvotes: 0
Views: 53
Reputation: 1269803
You are describing the coalesce()
function:
coalesce(col1, col2, col3)
You can use this in either a select
or update
.
Upvotes: 3