你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Applies to: ✅Microsoft Fabric✅Azure Data Explorer✅Azure Monitor✅Microsoft Sentinel
选择要包含、重命名或删除的列,并插入新的计算列。
结果中的列顺序由参数的顺序指定。 只有在参数中指定的列才包含在结果中。 输入中的任何其他列都会被删除。
Syntax
T| project
[ColumnName | (
ColumnName[,
])
=
] Expression [,
...]
or
T| project
ColumnName [=
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
表的 State
、EventType
、StormEvents
。
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 |
ENTERPRISE MUNI ARPT | 50 |
COLLIERVILLE | 6 |
... | ... |