Hello, I have a table of incidents with a level, an ID and an updateTime
The goal is to replace the NULL values of the column ‘Level’ by the previous row’s ‘Level ‘( for each ID) :
Assuming that your table is clustered in such a way that the data ordered by the clustered column(s) actually comes out in the order matching what you perceive as previous and next, you can try to use the quirky update to update your records:
For details, please refer to the excellent article by Jeff Moden titled Solving the Running Total and Ordinal Rank Problems. Robyn Page's SQL Server Cursor Workbench is also a must read on the subject. She is the one responsible for creating the quirky update term after all.