I want to update balance from another table, with sum function but im getting this error:
null value in column "balance" violates not-null constraint
Any suggestion how can i check to not update null values or to change query so that works?
This is my query:
update apt_profile
set payment_currency_code ='CC',
balance = (select sum(open_amount_total) from fnt_pym_profile where fnt_pym_profile.profile_id =apt_profile.id and status ='OPEN')
where payment_currency_code ='DD';
2
Answers
Use
COALESCE
.This should 0 the balance.
OR use ISNULL: