Description:
Perform aggregation over records in a channel.
Syntax:
ch.total(y,…)
Note:
The function performs aggregation over records in a channel. Parameter y is the aggregate function over cs. The function returns a single value when there is only one aggregate function; or returns multiple values in order for multiple aggregate functions. This is an attached computation.
Parameter:
ch |
Channel |
y |
Aggregate function, only support sum/count/max/min/top/avg/iterate; Parameter Gi should not be present when the function works with iterate(x,a;Gi,…) function |
Return value:
Numeric value or a sequence of numeric values
Example:
|
A |
|
1 |
=demo.cursor("select * from SCORES where CLASS = 'Class one'") |
|
2 |
=channel() |
Create a channel. |
3 |
=channel() |
|
4 |
=A1.push(A2,A3) |
Be ready to push A1’s data to channels A2 and A3. |
5 |
=A2.total(sum(SCORE)) |
Perform an aggregation over records in channel A2. |
6 |
=A3.total(sum(SCORE),count(SUBJECT),max(SCORE)) |
Perform multiple aggregations over records in channel A3. |
7 |
=A1.fetch() |
Fetch data from cursor A1 when operations in the channel begin to be executed and cursor data is pushed into the channel. |
8 |
=A2.result() |
|
9 |
=A3.result() |
|