共用方式為


project operator

Applies to: ✅Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

選取要包含的資料行、重新命名或捨棄,然後插入新的計算資料行。

結果中的數據行順序是由自變數的順序所指定。 結果中只會包含自變數中指定的數據行。 輸入中的任何其他數據行會卸除。

Syntax

T| project [ColumnName | (ColumnName[,])=] Expression [, ...]

or

T| projectColumnName [=Expression] [, ...]

Learn more about syntax conventions.

Parameters

Name 類型 Required Description
T string ✔️ 要投影特定數據行的表格式輸入。
ColumnName string 要出現在輸出中的數據行名稱或逗號分隔的數據行名稱清單。
Expression string 要透過輸入執行的純量表達式。
  • Either ColumnName or Expression must be specified.
  • If there's no Expression, then a column of ColumnName must appear in the input.
  • If ColumnName is omitted, the output column name of Expression will be automatically generated.
  • If Expression returns more than one column, a list of column names can be specified in parentheses. If a list of the column names isn't specified, all Expression's output columns with generated names will be added to the output.

Note

不建議傳回與輸入中現有數據行同名的新計算結果列。

Returns

具有數據行的數據表,其名稱為自變數。 包含與輸入數據表相同的數據列數目。

Examples

本節中的範例示範如何使用 語法來協助您開始使用。

The examples in this article use publicly available tables in the help cluster, such as the StormEvents table in the Samples database.

The examples in this article use publicly available tables, such as the Weather table in the Weather analytics sample gallery. 您可能需要修改範例查詢中的資料表名稱,以符合工作區中的資料表。

只顯示特定數據行

只顯示EventId資料表的 StateEventTypeStormEvents

StormEvents
| project EventId, State, EventType

Output

下表顯示前10個結果。

EventId State EventType
61032 ATLANTIC SOUTH Waterspout
60904 FLORIDA Heavy Rain
60913 FLORIDA Tornado
64588 GEORGIA Thunderstorm Wind
68796 MISSISSIPPI Thunderstorm Wind
68814 MISSISSIPPI Tornado
68834 MISSISSIPPI Thunderstorm Wind
68846 MISSISSIPPI Hail
73241 AMERICAN SAMOA Flash Flood
64725 KENTUCKY Flood
... ... ...

使用項目的潛在操作

下列查詢會重新命名數據行, BeginLocation 並從兩個現有數據行的計算中建立名為 TotalInjuries 的新數據行。

StormEvents
| project StartLocation = BeginLocation, TotalInjuries = InjuriesDirect + InjuriesIndirect
| where TotalInjuries > 5

Output

下表顯示前10個結果。

StartLocation TotalInjuries
LYDIA 15
ROYAL 15
GOTHENBURG 9
PLAINS 8
KNOXVILLE 9
CAROL STREAM 11
HOLLY 9
RUFFIN 9
企業市政 ARPT 50
COLLIERVILLE 6
... ...