v.25.6New Feature
Support lag and lead window functions
Supportlagandleadwindow functions. Closes #9887. #82108 (Dmitry Novik).
Why it matters
These functions enable accessing previous or next rows within a window frame, allowing users to perform comparisons and calculations across rows in a more efficient and expressive way.How to use it
Use thelag and lead functions within an OVER clause in your SELECT statements to access preceding or following row values. For example:SELECT
<columns>,
lag(<column>, <offset>, <default>) OVER (PARTITION BY ... ORDER BY ...) AS previous_value,
lead(<column>, <offset>, <default>) OVER (PARTITION BY ... ORDER BY ...) AS next_value
FROM <table>where
offset and default are optional parameters.