데이터에 있지만 값, 다음은 행의 이전 값을 가져옵니다
update t join
(select t.timestamp,
(select value
from t t2
where t2.timestamp < t.timestamp and t2.value is not null
order by t2.timestamp desc
limit 1
) as value
from t
) toupdate
on t.timestamp = toupdate.timestamp
set t.value = toupdate.value;
: 당신은 쉽게 업데이 트에이를 넣을 수 있습니다
select t.timestamp,
coalesce(value,
(select value
from t t2
where t2.timestamp < t.timestamp and t2.value is not null
order by t2.timestamp desc
limit 1
)
) as value
from t;
편집 :
행이 누락 된 경우이를 복제해야합니다. insert
에
이
select t.timestamp + interval 1 minute, value
from t left outer
t tnext
on tnext.timestamp = t.timestamp + interval 1 minute;
where tnext.timestamp is null
당신은이를 삽입 할 수 있습니다 : 한 행에없는 가정하면, 다음이 값을 얻을 일분보다 큰 격차를 들어
insert into t(timestamp, value)
select t.timestamp + interval 1 minute, value
from t left outer
t tnext
on tnext.timestamp = t.timestamp + interval 1 minute;
where tnext.timestamp is null;
, 나는 단순히 반복 제안 새로운 행이 발견되지 않을 때까지 insert
.
행이 누락 되었습니까? 아니면 행에 데이터가 누락되어 모든 분의 행이 있습니까? –
예 행이 누락되었습니다. 더 명확하지 않게해서 죄송합니다. 질문을 업데이트하겠습니다. –