共用方式為


as 運算子

將名稱系結至運算子的輸入表格式表示式。 這可讓查詢多次參考表格式表達式的值,而不需中斷查詢,並透過 let 語句系結名稱。

若要在單一查詢中優化運算符的 as 多個用法,請參閱 具名表達式

Syntax

T|as [hint.materialized=具體化] 名稱

深入瞭解 語法慣例

參數

名稱 類型 必要 Description
T string ✔️ 要重新命名的表格式表達式。
名稱 string ✔️ 表格式表達式的暫存名稱。
hint.materialized bool 如果 Materialized 設定 true為 ,則表格式表達式的值會如同具體 化 () 函數調用所包裝。 否則,將會在每個參考上重新計算值。

注意

  • as 提供的名稱將用於 unionwithsource= 資料行、findsource_ 資料行,以及 search$table 資料行。
  • 聯結的外部表格式輸入 ($left) 中,使用運算子所命名的表格式運算式,也可以用在聯結的表格式內部輸入 ($right) 中。

範例

在下列兩個範例中,聯集產生的 TableName 數據行將包含 『T1』 和 『T2』。

range x from 1 to 10 step 1 
| as T1 
| union withsource=TableName (range x from 1 to 10 step 1 | as T2)

或者,您可以撰寫相同的範例,如下所示:

union withsource=TableName (range x from 1 to 10 step 1 | as T1), (range x from 1 to 10 step 1 | as T2)

在下列範例中,聯結的「左邊」將會是:依 篩選Name == "Start"type == "Event",而聯結的「右側」將會是: MyLogTableMyLogTable依 和 篩選type == "Event"Name == "Stop"

MyLogTable  
| where type == "Event"
| as T
| where Name == "Start"
| join (
    T
    | where Name == "Stop"
) on ActivityId