I have below table :
Batch |
Account |
Account Balance |
Start_Date |
end_Date |
March Payment |
May Payment |
Jun Payment |
Jully Payment |
1 |
1001001 |
88$ |
1-Jun-22 |
30-Jun-22 |
10$ |
20$ |
100$ |
5$ |
1 |
1001002 |
50$ |
1-Jun-22 |
30-Jun-22 |
10$ |
40$ |
30$ |
0$ |
1 |
1001003 |
20$ |
1-Jun-22 |
30-Jun-22 |
2$ |
21$ |
100$ |
5$ |
we are counting commission amount with below conditions :
1- count only amount paid within Star and end date .
2- if customer paid more the account balance , don't count the extra
result :
Batch |
Start_Date |
end_Date |
March Payment |
May Payment |
Jun Payment |
Jully Payment |
1 |
1-Jun-22 |
30-Jun-22 |
0 |
0 |
122 |
|
122 =12+30+80