Skip to main content

// advent-of-postgres/day-11

Day 11 of 24IntermediateWindow functionsRunning totals

The Cloud Bill

Finance wants to know the day one team blew through its December budget. A running total answers it, if the window is right.

Opens 11 December 2026, 00:00 UTC

Every team has a December cloud budget of 10,000 candy canes. The wrapping team had a rough first week, and finance wants the exact day the team went over.

Each team's spend per day is in daily_costs:

Column Type Notes
team text Part of the primary key
day date 1 to 24 December
cost int Candy canes spent that day

The table already has the planned spend for the rest of the month, so the answer can be later than today.

Your task

On which day did the wrapping team's running December total first reach 10,000 candy canes or more?

Submit the date as YYYY-MM-DD.

Stuck? Show a hint

sum(cost) OVER (ORDER BY day) is a running total. Filter to one team first, or partition by team.

No database yet. You get a real Postgres database on Neon, free, with no account.
One statement at a time. Ctrl+Enter or Cmd+Enter runs it.

Download today's data as SQL to solve it on your own Postgres (14 or later).

Solved this puzzle? Share it.

Tag @thedevopsdaily and share it with the community.