COUNT

COUNT returns the number of elements in an array, or a series of elements. It can take an arbitrary number of optional arguments.

Function group: Statistical

Syntax

COUNT(arg1, [arg2...])

Arguments

Description

arg1

A number, string or an array of numbers or strings (or anything that can be coerced into being a number).

arg2

Optional. Same as arg1.

Example

Example 1: Find highest/lowest rated drivers

Let's say we're given a response with the following lists of driver IDs:

{
"data":{
"driver_performance_ratings":{
"highest":98,
"lowest":20,
"fleet":[
30,
60,
55,
99
]
}
}
}

If we want to find the amount of highest rated drivers and the lowest rated drivers, we use COUNT:

COUNT(data.driver_performance_ratings.highest, data.driver_performance_ratings.lowest)

This returns the following:

2

Example 2: Element or array as response

COUNT can also take arrays as arguments - so, in the event that a response could be either a single element or array, we could use COUNT

COUNT(data.driver_performance_ratings.highest, data.driver_performance_ratings.lowest, data.driver_performance_ratings.fleet)

This returns the following:

6