Lesson 10.5 · Pro

Forward fill and back fill

Fill gaps with the last known value (or the next one), the Postgres way.

In this lesson

  1. The problem: gaps after filling the calendar
  2. Step 1: number the groups with a running COUNT
  3. Step 2: spread the known value across its group
  4. Back fill: the next known value