LAG and LEAD

LAG returns the value of a previous row in the window and LEAD that of a following row, according to an offset and an optional default value. They let you compare a row with the previous one without a self-join. The first or last row has no neighbor and returns NULL without a default value.

Example

LAG(ca, 1) OVER (ORDER BY mois)

Related concepts

The whole glossary