select
    *,
    case 
        when lag(profit,1) over (order by profit_date asc) is null then profit
        else sum(profit) over (order by profit_date asc rows between unbounded preceding and current row) end as cumulative_profit
from 
    daily_profits