SQL Practice Logo

SQLPractice Online

LEAD, LAG, FIRST_VALUE, LAST_VALUE: Mistakes

Module: Window Functions

LAST_VALUE without proper frame

LAST_VALUE(...) OVER (... ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)

Default frame ends at current row. Specify full frame.

Always specify frame for LAST_VALUE

High

Gets current row, not last