sql - Not understanding how Coalesce works? -


i thought understood how coalesce works in oracle, reason simple select statement isnt bring supposed to. understand of coalesce goes through values in parenthesis until hits value in field looking at. in code 2 accounts in select have rr.rel_type of customer2. double checked looking @ values in racctrel. when run code though, 0 results come up. here code:

select lt.account,         rr.rel_type,        lt.transaction_date,         lt.amount,         lt.transaction_code,         ltc.fintran_tran_code,         fo.firm_name attorney,         lt.debtor_ssn,         replace(rr.name,';',',') debtor_name,         lt.description cost_description,        pd.owner legal_transactions lt,       legal_transaction_codes ltc,       firms_onboarded fo,       racctrel rr,      package_details pd,      raccount ra fo.attorney_id = lt.attorney_id , rr.account = lt.account , ra.account = lt.account , pd.package_id = ra.user_text_3 , ltc.transaction_code = lt.transaction_code , lt.batch_id = 865 , upper(rr.rel_type) = coalesce('customer1','primdebtor','customer2') , lt.account in ('17149146','17918854'); 

select account, rel_type racctrel account in ('17149146','17918854'); 

the results are:

17918854    customer2 17149146    customer2 

actually, works should:

here

and upper(rr.rel_type) = coalesce('customer1','primdebtor','customer2') 

the result of coalesce 'customer1' - first not null value, , here

17918854    customer2 17149146    customer2 

you have 'customer2'.

so it's correct:

and upper(rr.rel_type) = coalesce('customer1','primdebtor','customer2')  =>   , 'customer2' = 'customer1' 

is false.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -