Equivalent of LISTAGG in Vertica Hello Everyone! I'm trying to aggregate all the field values of a particular group in one field. For example, My input table looks like :-
FIELD1 GROUP1
A 1
A 2
B 1
B 2
C 1
C 3
3 null
and my output should look like :-
1 A,B,C
2 A,B
3 C
I can currently achieve this on Oracle by using the following function
SELECT GROUP1, LISTAGG(FIELD1, ',') WITHIN GROUP (ORDER BY FIELD1) AS GROUPED_FIELD
FROM <INPUT_TABLE>
GROUP BY GROUP1;
Is there a way i can do this in Vertica. Any help would be appreciated!!
Vertica just added support for LISTAGG in the latest 9.1.1: https://www.vertica.com/docs/9.1.x/HTML/index.htm#Authoring/SQLReferenceManual/Functions/Aggregate/LISTAGG.htm
However, it does not support ORDER BY clause, but you can use this workaround: