I have a table with dates, product code and price. But I have dates for business days, so it is missing weekends and holidays. I would like to add any missing days, so that those days contain the previous non-empty price.
For example: product_info
Date prod_code price
2019-12-12 123 17.00
2019-12-12 456 20.00
2019-12-12 789 22.00
2019-12-13 123 18.50
2019-12-13 456 21.50
2019-12-13 789 22.50
2019-12-16 123 17.00
2019-12-16 456 20.00
2019-12-16 789 22.00
I would like to be able to update/insert records such that the table would contain:
Date prod_code price
2019-12-12 123 17.00
2019-12-12 456 20.00
2019-12-12 789 22.00
2019-12-13 123 18.50
2019-12-13 456 21.50
2019-12-13 789 22.50
2019-12-14 123 18.50
2019-12-14 456 21.50
2019-12-14 789 22.50
2019-12-15 123 18.50
2019-12-15 456 21.50
2019-12-15 789 22.50
2019-12-16 123 17.00
2019-12-16 456 20.00
2019-12-16 789 22.00
From what I've searched for online, I probably will need to use a calendar table and perhaps some window functions, but Im not sure how to get started. Would greatly appreciate some help here.