When withdraw table has no data [Account No: 100.200.330.444]
and deposit table no data [Account No: 100.200.330.444]
, then only show NULL
.
But I want to show 0
.
I create virtual table
and make main balance
[Account No: 100.200.330.444]
My Code like deposit_amount - withdraw_amount = Result
When withdraws table empty, then feedback null
I want to show main_balance =0
CREATE VIEW xyz as select account_no as account_no,
CASE
when sum(deposit_amount)=null then 0
when sum(deposit_amount)=0 then 0
ELSE sum(deposit_amount)
END
-
(select
CASE
when sum(withdraw_amount)=null then 0
when sum(withdraw_amount)=0 then 0
ELSE sum(withdraw_amount)
END
from withdraws
)as balance from deposits group by account_no