![](https://static.wixstatic.com/media/11062b_fac51a38acf24ea2aa030216e01a0ea3f000.jpg/v1/fill/w_288,h_162,al_c,q_80,usm_0.66_1.00_0.01,blur_2,enc_auto/11062b_fac51a38acf24ea2aa030216e01a0ea3f000.jpg)
LEAD(expr [, N[, default]]) [null_treatment] over_clause
Returns the value of expr from the row that leads (follows) the current
row by N rows within its partition. If there is no such row, the return
value is default. For example, if N is 3, the return value is default
for the last two rows. If N or default are missing, the defaults are 1
and NULL, respectively.
N must be a literal nonnegative integer. If N is 0, expr is evaluated
for the current row.
Beginning with MySQL 8.0.22, N cannot be NULL. In addition, it must now
be an integer in the range 1 to 263, inclusive, in any of the following
forms:
o an unsigned integer constant literal
o a positional parameter marker (?)
o a user-defined variable
o a local variable in a stored routine
over_clause is as described in
https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html.
null_treatment is as described in the section introduction.
For an example, see the LAG() function description.
URL: https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html
Example