Skip to main content

group_concat function not working when used more than once in SQL

  • December 15, 2015
  • 1 reply
  • 11 views

Ash_Dev

I am trying to use group_concat as present as present in https://github.com/vertica/Vertica-Extension-Packages/blob/master/strings_package/src/GroupConcat.cpp to aggregate strings. However, it is not working when I use it more than once in a SQL. For example the SQL statement below failes with the error: ERROR: Cannot specify more than one user-defined transform function in the SELECT list:

select

   id

,  group_concat(name)

,  group_concat(city)

from dummy_table;

Is there a way to resolve this please?

1 reply

Sharon_Cutter
Forum|alt.badge.img
  • Participating Frequently
  • December 17, 2015

You can use the agg_concatenate User-Defined Aggregate Function in the sdk examples.  You can use that multiple times in a single SQL statement.

 

It doesn't use a delimiter in the example version, but see 

 

   https://community.dev.hpe.com/t5/Vertica-Forum/Does-Vertica-have-an-equivalent-to-MySQL-s-GROUP-CONCAT-function/td-p/208697

 

for how to either hard-code a delimiter or add one as a parameter.