Split mudarabah profit across depositors by weighted balance
Under a mudarabah profit-sharing account, each depositor's share of a month's distributable profit is proportional to their average balance that month, weighted against every depositor's combined average balance.
For March 2026, mudarabah_profit holds the total profit available to distribute. Split it across depositors in proportion to their avg_balance.
Return depositor, avg_balance and profit_share — their cut of the pool, rounded to 2 decimal places.
Schema
| depositor | TEXT |
| avg_balance | NUMERIC |
| month | DATE |
| total_profit | NUMERIC |
Example input
Stuck? Ask the coach for a nudge that won't give the answer away, or reveal the reference solution and a short walkthrough of why it works.