📖 Story
Rapido · Captain Streaks & Earnings
Rapido's weekend-surge planners want to know each captain's best 3-day earning stretch, to set realistic incentive targets. 'Three days' here means three calendar days — the current day plus the two days before it — not 'the last three shifts', because a captain who took a day off didn't earn anything that day. The obvious window function uses ROWS BETWEEN 2 PRECEDING AND CURRENT ROW, which quietly reaches back across days off. Earnings that haven't settled yet are NULL, and SUM skips them; a captain with nothing settled in any window should come out as NULL ('no settled earnings yet'), not 0.