1. The FOR XML PATH solution incorporates the reverse and stuff functions along with FOR XML PATH. from rows and concatenates them into a single string.". The STRING_SPLIT function allows us to use other symbols as a separator, but it has one limitation about this usage. The script below demonstrates the usage of the CONCAT function to concatenate two or more string values. array_agg (expression) -- input values, including nulls, concatenated into an array string . LISTAGG function support in PostgreSQL. Jessica, in addition what João said, the reason string_agg is not working may be the version of your DB. CONCAT and STUFF Functions in SQL Server 2012 - Database Journal Alternative to STRING_AGG in with SQL - Stack Overflow The implicit conversion to strings follows the existing rules for data type conversions. But the list is in no particular order. The LISTAGG function aggregates a set of string values for the group into one string by appending the string-expression values based on the order specified in the WITHIN GROUP clause. There are two widely available proprietary alternatives to listagg: group_concat and string_agg. With more and more data being exchanged over APIs, generating comma-separated strings are becoming a much more common requirement. How string_agg function and WITHIN GROUP works - Microsoft Q&A him_mca. When it isn't possible to solve your scenario with an ABAP CDS View there is an alternative solution creating an . Produce DISTINCT values in STRING_AGG. Its just that in SQL Server, it was available from 2017 version and on wards where as in Postgres it was available from version 9.0 (released in year 2010). expression - this is the string that we want to concatenate with a separator. It has been requested, but no success yet, as evidenced in these Connect items: (These are separated out merely to avoid cluttering the listing of more-commonly-used aggregates.) listagg — Rows to Delimited Strings - Modern SQL The default is NULL. A string, or an expression that evaluates to a string. So approaches that are loosely called "concatenating row values", "aggregate concatenation" etc. Then the SAP HANA optimizer can find the DISTINCT to be disposable.