Hello, please help. I need to make something like “lag() over partition” in PostgreSQL:
lag(col5) over (partition by col1,col2, col3 order by col4) as new_lag_column
example:
col1 | col2 | col3 | col4 | col5 | new_lag_column |
---|---|---|---|---|---|
John | Name1 | man | 01.08.2022 | 33 | null |
John | Name1 | man | 06.08.2022 | 38 | 33 |
John | Name6 | man | 07.08.2022 | 39 | null |
Mary | Name4 | woman | 04.08.2022 | 36 | null |
Peter | Name2 | man | 08.08.2021 | 40 | null |
Peter | Name2 | man | 02.08.2022 | 34 | 40 |
Peter | Name2 | man | 08.08.2022 | 40 | 34 |
Peter | Name2 | man | 09.08.2022 | 41 | 40 |