LISTAGG(columnName,'拼接符') WITHIN GROUP(ORDER BY clause) --order by 子句决定拼接内容的顺序
LISTAGG(columnName,'') WITHIN GROUP(ORDER BY clause) OVER (PARTITION BY ... ORDER BY ...)
实例
这是一张存放日常膳食安排的表,menu_date日期 cai_type(1/2/3)代表一日三餐 cai_code存放食物编码
1 SELECT menu_date,cai_type,LISTAGG(cai_code,'-') WITHIN GROUP (ORDER BY NULL) FROM customer_menu_config GROUP BY menu_date,cai_type