sql - Identify what source was used in ORACLE COALESCE -


how identify source coalesce has returned data for?

i want like:

select     coalesce(source1, source2) source, source_loaction datatable1 d1, datatable2 d2 

where have column in results displaying source data come from

answer:

as did usual , didn't word question enough had make needed out of provided:

-- using coalesce on more 1 field coalesce(d1.field1, d2.field1) field1, coalesce(d1.field2, d2.field2) field2, coalesce(d1.field3, d2.field3) field3,  case when       d1.field1 null ,     d1.field2 null ,     d1.field3 null ,  'source2' else 'source1' end datasource 

thanks :)

select     coalesce(source1, source2) source, ,coalesce(nvl2(source1,'source1',null), nvl2(source2,'source2',null)),  datatable1 d1, datatable2 d2 

Comments