FIRST_VALUE

FIRST_VALUE and LAST_VALUE return the first and last value of the window frame. With the default frame, LAST_VALUE stops at the current row, hence the classic trap: you must extend the frame to UNBOUNDED FOLLOWING to get the true last value of the partition.

Example

LAST_VALUE(prix) OVER (PARTITION BY produit ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)

Related concepts

The whole glossary