Skip to interview prep
Apexed

40. A seven-row moving average is being described as a seven-day average. When can those differ, and how would you correct it?

MediumSQL

Technical
Show model answer

Rows and calendar days are different units when dates are missing or several rows belong to a day. First aggregate to the intended daily grain and decide whether a day without activity means zero or missing data.

Create a calendar spine when needed, then use a frame or date condition that implements the agreed seven-day interval. Test gaps and boundary dates rather than assuming seven preceding records represent seven days.

What interviewers listen for

  • Distinguish row and time windows
  • Resolve zero versus missing days
  • Test gaps and interval boundaries
A seven-row moving average is being described as a seven-day average. When can those differ, and how would you correct it — Data & analytics interview question