|
GROUP_CONCAT (expr)
This function will merge non-null column values in accordance with the grouping condition and eventually returned. If a null value is returned is empty, the complete syntax is as follows:
GROUP_CONCAT ([DISTINCT] expr [, expr ...]
[ORDER BY {unsigned_integer | col_name | expr}
[ASC | DESC] [, col_name ...]]
[SEPARATOR str_val])
Example Column 1:
SELECT
EMP_ID,
SUM (VALUE1),
SUM (VALUE2),
SUM (VALUE3),
GROUP_CONCAT (REAS_1 SEPARATOR ';'),
GROUP_CONCAT (REAS_2),
GROUP_CONCAT (REAS_3)
FROM
ACT_GP_TEST
GROUP BY
EMP_ID
Column 2:
SELECT
EMP_ID,
SUM (VALUE1),
SUM (VALUE2),
SUM (VALUE3),
GROUP_CONCAT (REAS_1, REAS_2, REAS_3 SEPARATOR ';')
FROM
ACT_GP_TEST
GROUP BY
EMP_ID
The above column 1 and column 2 the difference is that the column 2 is the field REAS_1, REAS_2, REAS_3 field one by one as a complete merger.
The maximum length of the receive function group_concat_max_len environment variables defined, it defaults to 1024, of course, can be set higher. At the same time the effective maximum length is returned by the max_allowed_packet constraints.
Group_concat_max_len running is to modify the following syntax:
SET [GLOBAL | SESSION] group_concat_max_len = val;
The result returned is a binary or non-binary character, depending on the value of the function within the field itself. Usually when group_concat_max_len < = 512, in order to VARCHAR or VARBINARY, when the value is greater than the TEXT and BLOB. |
|
|
|