转载自:https://www.imooc.com/wenda/detail/575487
drop AGGREGATE group_concat(anyelement);
--1.自定义聚合函数group_concat
CREATE AGGREGATE group_concat(anyelement)
(
sfunc = array_append, -- 每行的操作函数,将本行append到数组里
stype = anyarray, -- 聚集后返回数组类型
initcond = '{}' -- 初始化空数组
);
select group_concat(id) from table_name
->{1,2,3,4,5,6,7,8,9,10}