count

Returns either the number of input records or the number of records for which an expression is non-NULL.

Syntax

count()
count(<expr>)

Arguments

<expr>

An expression to evaluate for each input record. count(<expr>) counts only records for which the expression evaluates to a non-NULL value. If every value is NULL, it returns 0.

Omit the argument to count every input record, including records whose fields are all NULL. Use count() for this form; SQL-style count(*) is not ScopeQL syntax.

Returns

Returns a value of type int.

Example

Count all events and the events that have a user identifier:

FROM events
AGGREGATE count() AS events, count(user_id) AS identified_events