Rolling Sum Reset on Date Gap

SQL coding challenge · Difficulty: hard · +300 XP

Sales data sometimes has gaps of multiple days (weekends, holidays, outages). The business wants a running total that RESETS whenever there is a gap of more than 1 day between consecutive entries — each "streak" of consecutive days gets its own counter.

Return: order_date, amount, running_total (resets on gap)

Sort by order_date ascending.

Solve this challenge on PySpark.in