A.news( X;xi:Fi,… )

Read(415) Label: concatenate, generate,

Description:

Compute field values based on a table sequence/record sequence, and concatenate them to generate a new one. 

Syntax:

A.news(X;xi:Fi,…)

Note:

The function computes field values based on record sequence X, concatenates the newly-computed fields to create a new table sequence/record sequence where parameter xi is field value of each record and Fi is the field name, which will be automatically identified according to parameter xi if Fi is omitted. When parameter xi is #i, it represents the ith field and the original field name will be used.

Parameters:

A

A table sequence/record sequence

X

A record sequence/integer; equivalent to to(X) if it is an integer, meaning the frequency of inserting each record in A

xi

Expression, whose results will be field values; the sign ~ used in the parameter references data from record sequence X instead of A. The sign # is used to represent a field with a sequence number

Fi

Field name of the new table sequence/record sequence; when omitted, it will be automatically identified

Return value:

A new table sequence/record sequecne

Example:

 

A

 

1

=demo.query("select * from EMPLOYEE")

 

2

=A1.group(GENDER;~:group,~.avg(SALARY):avg)

Perform group by GENDER

3

=A2.news(group;EID,NAME,GENDER, #3:surname, age(~.BIRTHDAY):age,SALARY+50: salary,A2.avg:AvgSalary)

A2 is composed of data groups; based on each group field values are computed and a table sequence is generated; and then table sequences are concatenated into a new one.

4

=A1.news(2;EID,NAME,GENDER,STATE,age(A1.BIRTHDAY):AGE)

Generate a new table sequence by inserting each record twice

5

=A1.group(DEPT).(~.group(GENDER))

 

Group records first by DEPT then by GENDER

6

=A5.news(~;A5.~.DEPT:DEPT,A5.~.~.GENDER:GENDER,A5.~.~.avg(SALARY):AvgSalary)

1559034619(1)

Get DEPT values and GENDER values from A5 to show the average salaries of different GENDERs in every DEPT

Related functions:

cs.new()