由于某种原因, trend表(趋势)数据缺少一部分记录. 现需要补充.
trend数据来自于history表(历史)
执行如下SQL即可补充相关数据:
注: 时间段根据自己的需求来.
代码语言:javascript复制INSERT INTO trend (itemid, clock, num, value_min, value_avg, value_max)
SELECT
itemid,
UNIX_TIMESTAMP(DATE_FORMAT(FROM_UNIXTIME(clock), '%Y-%m-%d %H:00:00')) as clock22,
COUNT(itemid) as num,
MIN(value) as value_min,
AVG(value) as value_avg,
MAX(value) as value_max
FROM
history
WHERE
itemid = xxxx and /*要所有item的 就取消这一行*/
clock BETWEEN UNIX_TIMESTAMP('2023-10-12 00:00:00') AND UNIX_TIMESTAMP('2023-10-13 00:00:00')
GROUP BY
itemid,
clock22;