I search a price every 5 minutes. But it can be not changed during 10 minutes, so how can I have the previous price ?
datediff(minute,cast(tmp.END_TIME as time),cast(tmp.time as time)) as delta,
ROW_NUMBER() OVER(PARTITION BY tmp.sid
ORDER BY time asc) AS rk
FROM #tmp tmp where sid='11111111111' and datediff(minute,cast(tmp.end_time as time),cast(tmp.time as time)) between 10 and 15