create stream if not exists stream_dwd_agg_m interval(1m) sliding (1m) from zhsc_dev.dwd_measure_point partition by device_id, point_id stream_options ( watermark (1m) | fill_history (1) ) into zhsc_dev.dwd_agg_m tags ( device_id nchar (64) as device_id, point_id nchar (128) as point_id ) as select _wstart as ts, _wend as wend, first (v) as first_v, last (v) as last_v, last (v) - first (v) as diff_v, avg(v) as avg_v, sum(v) as sum_v, max(v) as max_v, min(v) as min_v, count(*) as row_count from %%trows partition by device_id, point_id interval(1m) sliding (1m);
create stream if not exists stream_dwd_agg_m
interval(1m) sliding (1m)
from
zhsc_dev.dwd_measure_point partition by device_id, point_id
stream_options ( watermark (1m) | fill_history (1) )
into
zhsc_dev.dwd_agg_m tags ( device_id nchar (64) as device_id, point_id nchar (128) as point_id )
as
select
_twstart as ts,
_twend as wend,
first (v) as first_v,
last (v) as last_v,
last (v) - first (v) as diff_v,
avg(v) as avg_v,
sum(v) as sum_v,
max(v) as max_v,
min(v) as min_v,
count(*) as row_count
from
zhsc_dev.dwd_measure_point
where
device_id = %%1 and point_id = %%2 and _c0 >= _twstart and _c0 < _twend;