Description:
Group records in a cluster cursor and return a synchronously segmented cursor.
Syntax:
cs.groupx(x:F,…;y:G…;n)
Note:
The function groups records in cluster cursor cs by grouping expression x to create a new cluster cursor consisting of fields F,...G,… sorted by the grouping field x. G field gets values by computing y – the aggregate function with which records of cs is aggregated – on each group.
Parameter:
cs |
A cluster cursor |
x |
Grouping expression |
F |
Resulting field name |
y |
An aggregate function on cs, which only supports sum/count/max/min/top/avg/iterate; when the function works with iterate(x,a;Gi,…) function, the latter’s parameter Gi should be omitted |
G |
Aggregate field name |
n |
Number of buffer rows; if the number of groups reaches n, write the grouping result to a temporary file; its value is n times of the default, which is automatically calculated, if n<1 |
Return value:
A cluster cursor
Example:
|
A |
|
1 |
[192.168.31.72:8281, 192.168.31.72:8291] |
|
2 |
=file("orderpart.ctx":[1], A1) |
Open a cluster file. |
3 |
=A2. open () |
Open a cluster composite table. |
4 |
=A3.cursor() |
Return a cluster cursor. |
5 |
=A4.groupx(EID:ID;count(~):IdCount) |
Group A7 and perform count by EID, and return a cluster cursor. |
6 |
=A5.fetch() |
|
7 |
=A3.cursor() |
|
8 |
=A7.groupx(if(EID==4,1,2):ID;count(~):IdCount) |
Put records where EID is 4 into the first group and others into the second group, and then count the EID values. |
9 |
=A8.fetch() |
|
10 |
=A7.groupx(if(EID<=10):ID;count(~):IdCount;2) |
Since the number of groups reaches 2, write the grouping result to a temporary file. |