Skip to content
masterclass Buddy

PostgreSQL · Function

lead

lead returns a value from a later row in the current window partition. It defaults to looking one row ahead and returns NULL when that row does not exist.

Last updated

Syntax

lead ( value anycompatible [ , offset integer [ , default anycompatible ] ] ) → anycompatible

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • lag
  • first_value
  • last_value
  • nth_value
  • OVER
  • PARTITION BY

Source: PostgreSQL: Documentation: 18: 9.22. Window Functions. Checked 2026-11-03.