答案 0 :(得分:0)
如果您只想进行更改,请使用大多数数据库支持的ANSI标准lag()
函数:
select zone, temperature, time
from (select t.*,
lag(temperature) over (partition by zone order by time) as prev_temperature
from t
) t
where prev_temperature is null or prev_temperature <> temperature;
答案 1 :(得分:0)
您可以使用lead
获取下一行的值,并在下一行的值相同时删除行。
with cte as (select t.*
,lead(temperature) over(partition by zone order by time) as next_temp
from tbl t
)
delete from cte
where next_temp is not null and next_temp=temperature