I have a table
MissingData
1
10
NULL
NULL
22
NULL
The desired output will be
MissingData
1
10
10
10
22
22
i.e. the nulls will be filled up by the previous value until a new value is appearing.
I can solve this by using loop but my requirement is to solve it by CTE in which I am not so comfortable as of now.
Thanks
The order of the values in your list is implicitly part of the problem. This order must be stored as part of the data in the source table, otherwise the problem can’t be solved reliably, even in a loop. I’ve added an “ordinal” column to represent the missing ordering.