sql - when one column null then get data from other column -
hope can help. not showing whole query because don't think required want try , query see there null value in 'street' in 'free address' , put result in there. i'm guessing involves case expression or concat
current result
select idnum street free address id idnum street free address 1 stack on flow null 2 null stack exchange 3 downing street null
required result - note free address column doesn't need on display, purpose of demonstration.
idnum street free address 1 stack on flow null 2 stack exchange stack exchange 3 downing street null
many help
the coalesce()
function this:
select idnum, coalesce(street, free_address) street, free_address id;
note: id
strange name table , free address
isn't valid column name (because of space).
coalesce()
ansi standard function available in databases.
Comments
Post a Comment