Skip to content
Advertisement

Combine lead and lag function without overlap

I have this table:

I need to get an output like this:

I’ve tried a normal lead

window function, but that would only show the first ‘Creation’ and not that last ‘Pending’ that I need.

Advertisement

Answer

Your table has N records (3 in the example provided) when query must return N + 1 (4); let’s modify the initial data in order to query N + 1 records:

Fiddle

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement