Query editor
-- Outstanding over timeWITH daily AS (SELECT day,SUM(CASE WHEN flow_type='disb' THEN usd ELSE 0 END) AS d,SUM(CASE WHEN flow_type='repay' THEN usd ELSE 0 END) AS rFROM query_9001697 GROUP BY 1)SELECT day, SUM(d - r) OVER (ORDER BY day) AS outstanding_to_borrowers_usdFROM dailyORDER BY day