你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

sample-distinct 运算符

适用于:✅Azure 数据资源管理器Azure Monitor✅ Sentinel

返回单个列,该列包含所请求列的非重复值,且数目不超过指定数目。

运算符针对性能而不是公平性进行优化;结果可能存在严重偏差,不应用于任何需要统计准确性的用途。

Syntax

T| sample-distinctNumberOfValuesofColumnName

详细了解语法约定

Parameters

Name 类型 Required Description
T string ✔️ 输入表格表达式。
NumberOfValues int、long 或 real ✔️ 要返回的 T 的非重复值的数目。 可以指定任何数值表达式。
ColumnName string ✔️ 要从中采样的列的名称。

Tip

Examples

本节中的示例演示如何使用语法帮助你入门。

本文中的示例使用 帮助群集中的公开可用表,例如 StormEventsSamples 数据库中的表。

本文中的示例使用公开可用的表,例如 Weather 天气分析 示例库中的表。 可能需要修改示例查询中的表名称以匹配工作区中的表。

从总体获取 10 个非重复值

StormEvents | sample-distinct 10 of EpisodeId

Output

EpisodeId
11074
11078
11749
12554
12561
13183
11780
11781
12826

进一步计算示例值

let sampleEpisodes = StormEvents | sample-distinct 10 of EpisodeId;
StormEvents 
| where EpisodeId in (sampleEpisodes) 
| summarize totalInjuries=sum(InjuriesDirect) by EpisodeId

Output

EpisodeId totalInjuries
11091 0
11074 0
11078 0
11749 0
12554 3
12561 0
13183 0
11780 0
11781 0
12826 0