WITH (Azure Stream Analytics)
指定可供查詢中的 FROM 子句參考的暫存具名結果集。 此結果集定義於單一 SELECT 陳述式的執行範圍內。
注意
WITH 子句具有相應放大查詢的特殊用途。 如需詳細資訊,請參閱 調整 Azure 串流分析作業
語法
WITH
<result_set_name1> AS
( SELECT_query_definition1 ),
[<result_set_name2> AS
( SELECT_query_definition2 )
[...n] ]
引數
result_set_name
這是可供 SELECT 陳述式的 FROM 子句參考的暫存結果集名稱。 此名稱必須與查詢範圍內定義的任何其他 result_set_name 名稱不同。
SELECT_query_definition
指定 SELECT 陳述式,其結果集會填入 result_set_name。
範例
WITH
NormalReadings AS
(
SELECT *
FROM Sensor
WHERE Reading < 100 AND Reading > 0
),
Averages AS
(
SELECT SensorId, AVG(Reading) as AvgNormalReading
FROM NormalReadings
GROUP BY SensorId, TumblingWindow(minute, 1)
),
BadAverages AS
(
SELECT *
FROM Averages
WHERE AvgNormalReadings < 10
)
SELECT * INTO outputAlerts FROM BadAverages
SELECT * INTO outputLog FROM NormalReadings