Skip to content
Advertisement

fill in missing dates of date_trunc with last row data

I currently have a query for chart using date_trunc and the result is something like this

dates with no value are skipped , however I need it to be like this

notice how for 7th and 8th it will use the last available data which is in 6th. Will appreciate any help!

Advertisement

Answer

Use generate_series to generate a row for each day, then select the last available data from your query result:

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