Skip to content
Advertisement

Fill the data on the missing date range

I have a table will the data with exist data below:

There are some missing date on the table, example 20200829 to 20200831 and 20200903. Those closing quantity of the missing date will be follow as per previous day closing quantity.

I would like select the table result in a full range of date (show everyday) with the closing quantity. Expected result,

Beside using cursor/for loop to insert the missing date and data 1 by 1, is that any SQL command can do it at once?

Advertisement

Answer

You have option to use recursive CTE.

For reference Click Here

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