View Table: don't work properly. I have two tables
Depositswithdraws
If:
Account no = 101
balance = 100 $
Account no = 102
balance = 50 $
When i withdraw some money Like this account A/C 101 Withdraw Amount 10$
Now result : is minus all account balance
Current balance:
Account no = 101
balance = 90 $ -10 $
Account no = 102
balance = 40 $ -10 $ // But 50
every account minus Deposit balance
CREATE VIEW main_balance_new as select account_no as account_no,
SUM(deposit_amount)-(select
CASE
WHEN withdraw_amount IS NULL THEN 0
ELSE SUM(withdraw_amount)
END
from withdraws) as balance from deposits group by account_no
How can i solve this problem?