COUNT_EACH

The number of items grouped by the given key.

Syntax

COUNT_EACH([MAX VALUES, ]GROUP)

Arguments

MAX VALUES: The maximum number of entries that can be counted (default: 2,147,483,647). When MAX VALUES is omitted, the limit is simply set to the default value. GROUP: The field you would like counted.

Returns

An integer

Notes

"EACH" Aggregate Functions, such as this one, only work when emitting hierarchical data.

Example

Data

[
   {
      "user":"A01",
      "level":1,
      "score":25
   },
   {
      "user":"A01",
      "level":2,
      "score":48
   },
   {
      "user":"A01",
      "level":2,
      "score":81
   },
   {
      "user":"A01",
      "level":2,
      "score":81
   },
   {
      "user":"B02",
      "level":1,
      "score":23
   },
   {
      "user":"B02",
      "level":1,
      "score":29
   }
]

Query

Display hierarchical results of each value, with the matching count of the value. This resembles a count field + group by query, except that the results are formatted as a single hierarchy.

Results

COUNT COUNT(*) COUNT DISTINCT

Dialog

Last updated

Was this helpful?