LAG() gets a value from a previous row.
LEAD() gets a value from a future row.
Example:
LAG(event_time) OVER (
ORDER BY event_time
)gets the previous event time.
Then:
event_time - LAG(event_time) OVER (...)
can calculate the time between events.
LEAD() is useful when comparing the current event with the next event.