Here’s how to use concat() function.
Description:
Concatenate parameters into a string.
Syntax:
concat(xi,…)
Note:
The function concatenates parameters xi,… into a string in which quotation marks will not be used.
Parameter:
xi |
Any value that can be converted to a string; if it is a sequence, it will be broken up before concatenation. |
Return value:
String
Example:
|
A |
|
1 |
=demo.query("select * from SCORES where SCORE>90") |
|
2 |
=A1.(SCORE) |
|
3 |
=A1.(SUBJECT) |
|
4 |
=concat(A2,A3) |
979691939797979691939797PEEnglishPEEnglishMathMathPEEnglishPEEnglishMathMath. |
5 |
=concat(2,3,"a") |
23a. |
Related function:
Description:
Use a delimiter to concatenate values of an aggregation field.
concat(x;d)
Note:
The function concatenates values of aggregation field x using the delimiter d; concatenate them without using a delimiter when parameter d is absent. It can only work as the aggregate function in the groups() function.
Parameter:
x |
Aggregation field name. |
d |
A delimiter. |
Option:
@c |
Concatenate with the comma. |
@i |
Enclose each to-be-concatenated value with the single quotation marks. |
@q |
Enclose each to-be-concatenated value with the double quotation marks; won’t quote them when the option is absent. |
Return value:
String
Example:
|
A |
|
1 |
=demo.query("select EID,NAME,DEPT from employee") |
Return a table sequence.
|
2 |
=A1.groups(DEPT;concat(NAME;"_"):ALL_NAME) |
Group A1’s table sequence by DEPT field, concatenate NAME values in each group with the delimiter _ and return them to ALL_NAME column.
|
3 |
=A1.groups(DEPT;concat@c(NAME):ALL_NAME) |
Work with @c option to use the comma as the delimiter.
|
4 |
=A1.groups(DEPT;concat@q(NAME):ALL_NAME) |
Work with @q option to enclose each to-be-concatenated value with the double quotation marks.
|
5 |
=A1.groups(DEPT;concat@i(NAME):ALL_NAME) |
Work with @i option to enclose each to-be-concatenated value with the single quotation marks.
|
6 |
=A1.groups(DEPT;concat@i(NAME;"|"):ALL_NAME) |
Work with @i option to enclose each to-be-concatenated value with the single quotation marks, and use | as the delimiter.
|
Description:
Concatenate members of a sequence with the delimiter and return result as a string.
Syntax:
A.concat(d)
Note:
The function concatenates members of A delimited by d and returns result as into a string; the sub-sequences of the string will be handled in a same way. Concatenate the members without a delimiter when parameter d is omitted.
Option:
@q |
Add quotation marks to string members when concatenating them into a string. If this option is omitted, do not use the quotation marks. |
@c |
Concatenate with the comma. |
@i |
Enclose string members to be concatenated with single quotes. |
@n |
If members of the sequence are also sequences, create a new line after concatenate members of each sequence members with the delimiter. The operations are equivalent to A.(~.concat(d)).concat("\n"). If there are other options, perform the concatenation in the inner layer of the function. |
@y |
Use this option when parameter d is an array. In the array, each member is regarded as representing the length of the corresponding segment of characters, and the result is their combination of the specified lengths. For a numeric member of A, add 0s before it to represent the extra digits; and for a string member, add white spaces after it to reach the specified number of characters. |
Parameter:
A |
A sequence of strings. |
d |
Delimiter. |
Return value:
String
Example:
|
A |
|
1 |
=[1, ["a","b"],[2,"c"]] |
|
2 |
=A1.concat() |
Concatenate members of sequence A1 without using the separator; the result is 1[ab][2c] . |
3 |
=A1.concat(":") |
Concatenate members of sequence A1 using colon as the separator; the result is 1:[a:b]:[2:c] . |
4 |
=A1.concat@q() |
Use @q option to do the concatenation with the quotation marks retained; the result is 1["a""b"][2"c"]. |
5 |
=A1.concat@c() |
Use @c option to do the concatenation with comma being the separator; the result is 1,[a,b],[2,c]. |
6 |
=A1.concat@i() |
Use @i option to do the concatenation with members enclosed by single quotation marks; the result is 1['a''b'][2'c']. |
7 |
=[[1,2,3], ["a","b"],[2,"c"]] |
Return a sequence of sequences. |
8 |
=A7.concat@n("-") |
Use @n option to join members of each sub-sequence in sequence A7 with the separator “-” and use the line break for a new sub-sequence; the result is as follows:
|
9 |
=A7.concat@nc() |
Use @nc options to do the concatenation; below is the result:
|
10 |
=[123,"hello",789,"world"].concat@y([3,8,6,5]) |
As @y option is present, add white spaces after the corresponding string and 0s before the corresponding number to reach the specified number of characters. Below is the returned result:
|