My data
B_STAFF_CODE PERIOD_COLL
----------------------------------
1111111 201901
2222222 201901
1111111 201902
3333333 201903
----------------------------------
我尝试通过Netteza中的SQL语句使用功能'LISTAGG' 我得到如下错误,
错误:函数'LISTAGG'不是解析集合,而是使用窗口规范调用
SELECT B_STAFF_CODE,
LISTAGG(PERIOD_COLL, ' , ') WITHIN GROUP (ORDER BY PERIOD_COLL) as CONCAT_PERIOD
FROM F_STAFF_MASTER
GROUP BY B_STAFF_CODE;
B_STAFF_CODE CONCAT_PERIOD
----------------------------------
1111111 201901, 201902
2222222 201901
3333333 201903
----------------------------------
答案 0 :(得分:0)
您可以使用GROUP_CONCAT()
SELECT B_STAFF_CODE,
GROUP_CONCAT(PERIOD_COLL, ' , ') as CONCAT_PERIOD
FROM F_STAFF_MASTER
GROUP BY B_STAFF_CODE