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)