I have a table with unique timestamps.
The table name is t1
scedtimestamp
2021-09-30 23:45:14
2021-09-30 23:40:13
2021-09-30 23:35:14
2021-09-30 23:30:14
2021-10-13 07:55:13
I need to write a query using cursor on Redshift to compare those timestamps for every 5 mins. something like this :
select electricalbus,shadowprice from wm_lmp where scedtimestamp between '2021-09-30 23:45:14' and '2021-09-30 23:50:14'
all the dates in the above code need to be replaced with timestamp and timestamp + 5 mins
begin;
declare cs cursor for
select distinct scedtimestamp as name from t1
fetch next from cs into temp;
select electricalbus,shadowprice from wm_lmp where scedtimestamp between temp and dateadd(m,5,temp)
close cs;
commit;
but my code gives syntax errors says - ERROR: syntax error at or near "into" Position. Can someone help me out?