我试图用流分析作业中的最后 10 秒平均值替换空值。这需要在流和我在 With 子句中计算的平均值之间进行自连接。它给了我重复(我得到相同的记录两次或三次)?关于什么是错的或如何正确地做的任何建议?我的查询是:
WITH MV AS ( Select AVG([Sensor_1]) AS [Sensor_1] From [input] GROUP BY SlidingWindow(second, 10))
SELECT [input].[ID]
,[input].[Timestamp]
,[input].[Result]
,CASE
WHEN [input].[Sensor_1] = 0
THEN [MV].[Sensor_1] ELSE [input].[Sensor_1]
END [Sensor_1]
,[input].[Sensor_2]
,[input].[Sensor_3]
FROM [input]
LEFT OUTER JOIN [MV]
ON DateDiff(second, [input], [MV]) BETWEEN 0 AND 10