T.f(C)

Read(900) Label: attached table, aggregation,

Description:

Perform an aggregate operation over an attached table’s column.

Syntax:

T.f(C)

Note:

The function performs an aggregation (function f) over the multiple records corresponding to one value in a specific column of an attached table.

Parameter:

T

An attached table

f

An aggregate operation performed over the attached table; support count, sum, max, min, avg, top and iterate

C

An attached table’s column

Example:

 

A

 

1

=create(k1,v1).record([1,10,2,20,3,30,4,40,10,100])

Create a table sequence:

2

=create(k1,k2,v2).record([1,1,"a",2,4,"c",2,8,"b"])

Create a table sequence:

3

=file("D:/ckv.ctx")

 

4

=A3.create(#k1,v1)

Create the composite table’s base table.

5

=A4.attach(table2,#k2,v2)

Add an attached table to the base table.

6

=A4.append(A1.cursor())

Append data to the base table.

7

=A5.append(A2.cursor())

Append data to the attached table.

8

=A4.cursor(k1,table2.sum(k2):k2_sum).fetch()

Perform a sum operation over each value of column k2 in attached table table2, and name the new column k2_sum.

9

=A4.cursor(table2.count(k2)).fetch()

Perform count operation over each value of column k2 in attached table table2.

10

=A4.cursor(table2.max(k2)).fetch()

Perform max operation over each value of column k2 in attached table table2.

11

=A4.cursor(table2.min(k2)).fetch()

Perform min operation over each value of column k2 in attached table table2.

12

=A4.cursor(table2.avg(k2)).fetch()

Perform average operation over each value of column k2 in attached table table2.

13

=A5.cursor().top(2;k2)

Return the records corresponding to the first two smallest values in column k2 in entity table table2.

14

=A5.cursor().derive(iterate(~~*2,10):F1).fetch()

Perform an iteration over entity table table2.