count_distinct
count_distinct 函数用于返回组内具有不同值的行数。它通常与 match 结合使用,以获取数据中特定组的计数。
| 语法 | 形参数据类型 | 返回值类型 |
|---|---|---|
count_distinct(expression) |
STRING |
NUMBER |
代码示例
返回不同用户登录的次数
返回不同成功用户登录的随时间变化次数。
metadata.event_type = "USER_LOGIN" $security_result = security_result.action $security_result = "ALLOW" $date = timestamp.get_date(metadata.event_timestamp.seconds, "America/Los_Angeles") match: $security_result, $date outcome: $event_count = count_distinct(metadata.id)