Returns a delimited list of values for every row in a group.
LIST( [ALL | DISTINCT] string-expresssion [, 'delimiter-string'] [ORDER BY order-by-expression [ ASC | DESC ], ... ] )
order-by-expression cannot be an integer literal. However, it can be a variable that contains an integer literal.
When an ORDER BY clause contains constants, they are interpreted by the optimizer and then replaced by an equivalent ORDER BY clause. For example, the optimizer interprets ORDER BY 'a' as ORDER BY expression.
ORDER BY expression1, 'a', expression2
ORDER BY expression1, 'b', expression2, 'c', expression3
ORDER BY expression1, expression2, expression3
LONG VARCHAR
The LIST function returns the concatenation (with delimiters) of all the non-NULL values of X for each row in the group. If there does not exist at least one row in the group with a definite X-value, then LIST( X ) returns the empty string.
NULL values and empty strings are ignored by the LIST function.
A LIST function cannot be used as a window function, but it can be used as input to a window function.
This function supports NCHAR inputs and/or outputs.
SAP Sybase IQ supports SQL/2008 language feature F441, "Extended set function support", which permits operands of aggregate functions to be arbitrary expressions that are not column references.
SAP Sybase IQ does not support optional SQL/2008 feature F442, "Mixed column references in set functions". SAP Sybase IQdoes not permit the arguments of an aggregate function to include both a column reference from the query block containing the LIST function, combined with an outer reference.
SELECT LIST( Street ) FROM Employees WHERE GivenName = 'Thomas';
SELECT LIST( EmployeeID ) FROM Employees GROUP BY DepartmentID;
LIST( EmployeeID ) |
---|
102,105,160,243,247,249,266,278,... |
129,195,299,467,641,667,690,856,... |
148,390,586,757,879,1293,1336,... |
184,207,318,409,591,888,992,1062,... |
191,703,750,868,921,1013,1570,... |
SELECT LIST( EmployeeID ORDER BY Surname ) AS "Sorted IDs" FROM Employees GROUP BY DepartmentID;
Sorted IDs |
---|
1013,191,750,921,868,1658,... |
1751,591,1062,1191,992,888,318,... |
1336,879,586,390,757,148,1483,... |
1039,129,1142,195,667,1162,902,... |
160,105,1250,247,266,249,445,... |
SELECT LIST( EmployeeID, ';' ORDER BY Surname ) AS "Sorted IDs" FROM Employees GROUP BY DepartmentID;
Sorted IDs |
---|
1013;191;750;921;868;1658;703;... |
1751;591;1062;1191;992;888;318;... |
1336;879;586;390;757;148;1483;... |
1039;129;1142;195;667;1162;902; ... |
160;105;1250;247;266;249;445;... |
SELECT LIST( EmployeeID ORDER BY Surname, ';' ) AS "Sorted IDs" FROM Employees GROUP BY DepartmentID;