Skip to main content

FIRST_VALUE & LAST_VALUE

Learn FIRST_VALUE & LAST_VALUE (Window Functions, MySQL) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Introduction FIRST_VALUE(expr) returns the value from the first row of the window frame and LAST_VALUE(expr) from the last row of the frame. Careful: with an ORDER BY, the default frame ends at the current row , so LAST_VALUE returns the current row's value unless you widen the frame.

More lessons in Window Functions