By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
3 rows affected
5 rows affected
| id | accountname | accountcode |
|---|---|---|
| 1 | client1 | 11 |
| 2 | client2 | 111 |
| 3 | client3 | 112 |
| id | debit | credit | accountcode |
|---|---|---|---|
| 1 | 500 | null | 11 |
| 2 | null | 200 | 11 |
| 3 | 700 | null | 111 |
| 4 | 300 | null | 112 |
| 5 | null | 400 | 112 |
| accountname | total_debit | total_credit | cumulative_balance |
|---|---|---|---|
| client1 | 500 | 200 | 300 |
| client2 | 700 | null | 1000 |
| client3 | 300 | 400 | 900 |
Warning: Null value is eliminated by an aggregate or other SET operation.