Reduce operator
Reduce
Syntax
reduce <var> = <operator> [( <var> )] [ , ... ];
TypeQL supports the following reduce operators:
-
count
— total number of answers, or, when used with a variable, number of distinct values of the variable, -
max
— the maximum value of the variable, -
min
— the minimum value of the variable, -
mean
— the arithmetic mean of the values of the variable, -
median
— the median value of the variable, -
std
— the sample standard deviation of the values of the variable, -
sum
— the sum of the values of the variable.
Grouping
When groupby
is used within a reduce, the answer stream is subdivided into groups based on the value of the grouping variable. The
reduction is then performed separately within each such group. The output of a reduce
with groupby
is a stream of rows, one for each
value of the grouping variable.