P18SQLAdvancedInterpret18 min

Rolling 7-Day Revenue

Build a rolling revenue metric that does not hide days with zero sales.

#window-functions#date-spine#rolling-metrics

Scenario

Leadership wants a seven-day revenue trend, including days where no orders occurred.

Problem statement

Explain how to create a complete daily series and calculate rolling seven-day revenue.

Your Task

  1. Generate or use a calendar date spine.
  2. Left join daily revenue onto every date.
  3. Use a seven-row window only after zero-sale days are present.

Related Concepts

Date spinesWindow framesMissing dates

Ready to count this problem?

Mark it complete when you have reasoned through the solution in your own words.