I have a table that gives me data every 15 minute and I need that range of time. I noticed that sometimes I don't have data for 3/4 hours but I need to duplicate the last row available with the missing timestamp.
Example:
product_id | total_revenue | timestamp |
---|---|---|
1 | 50 | 01-01-2021 00:00:00 |
2 | 17 | 01-01-2021 00:00:00 |
3 | 30 | 01-01-2021 00:00:00 |
1 | 67 | 01-01-2021 00:15:00 |
2 | 31 | 01-01-2021 00:15:00 |
1 | 67 | 01-01-2021 00:30:00 |
2 | 31 | 01-01-2021 00:30:00 |
3 | 33 | 01-01-2021 00:30:00 |
But I need an output like:
product_id | total_revenue | timestamp |
---|---|---|
1 | 50 | 01-01-2021 00:00:00 |
2 | 17 | 01-01-2021 00:00:00 |
3 | 30 | 01-01-2021 00:00:00 |
1 | 67 | 01-01-2021 00:15:00 |
2 | 31 | 01-01-2021 00:15:00 |
3 | 30 | 01-01-2021 00:15:00 |
1 | 67 | 01-01-2021 00:30:00 |
2 | 31 | 01-01-2021 00:30:00 |
3 | 33 | 01-01-2021 00:30:00 |
I have a select statement like:
select product_id,total_revenue,timestamp from revenue
(I calculate the difference between two consecutive rows too).
Does anybody know how to help me?