Perfect! The last possible type of
LEAD(x, y, z) takes three arguments:
LEAD(OpenDate,2,'2000-01-01') OVER(ORDER BY OpenDate ASC) AS Lead
The third argument (
z) tells the function what it should return if no matching value is found. Previously, the last rows got
NULLs from the function, because there were no "lead" (further) rows for them. Now, you can specify what should be displayed in such cases instead of the default
NULL. Here, we show '2000-01-01'. Note that this value must be of the same type as the column itself: if you show dates with
LEAD(), the last argument must be a date too. You can't show "not available" or 0 instead.