I have a table that has records in 5 minute increments that looks like the following:
UDSNSI TIMESTAMP
-8134 7/20/2016 4:30:00 AM
-8125 7/20/2016 4:35:00 AM
-8098 7/20/2016 4:40:00 AM
I need to select from in such a way that would create a result for every minute up to the time in the next row from now to the last 5 hours. For example:
UDSNSI TIMESTAMP
-8134 7/20/2016 4:30:00 AM
-8134 7/20/2016 4:31:00 AM
-8134 7/20/2016 4:32:00 AM
-8134 7/20/2016 4:33:00 AM
-8134 7/20/2016 4:34:00 AM
-8125 7/20/2016 4:35:00 AM
-8125 7/20/2016 4:36:00 AM
-8125 7/20/2016 4:37:00 AM
...
I feel like I can use "CONNECT BY" but I can't seem to figure out how to tell it to use the TIMESTAMP from one row as the start and the next row as the end each time.
select udsnsi,
timestamp
from plan
where timestamp <sysdate and timestamp >= sysdate - 5/24
connect by timestamp <=
(
select .... timestamp from row X and row X + 1
and create a row for every minute value in between
using X's udsnsi value
)