首先,您需要为编译udx
agg_concatenate。
-- Shell commandscd /opt/vertica/sdk/examples/AggregateFunctions/g++ -D HAVE_LONG_INT_64 -I /opt/vertica/sdk/include -Wall -shared -Wno-unused-value -fPIC -o Concatenate.so Concatenate.cpp /opt/vertica/sdk/include/Vertica.cpp-- vsql commandsCREATE LIBRARY AggregateFunctionsConcatenate AS '/opt/vertica/sdk/examples/AggregateFunctions/Concatenate.so';CREATE AGGREGATE FUNCTION agg_concatenate AS LANGUAGE 'C++' NAME 'ConcatenateFactory' LIBRARY AggregateFunctionsConcatenate;
然后,您可以执行如下查询:
select id, rtrim(agg_concatenate(name || ', '),', ') agfrom mytablegroup by 1order by 1
使用rtrim摆脱最后一个’,’。
如果您需要以某种方式对聚合进行排序,则可能需要在嵌入式视图中或使用first进行选择/排序。



