Reputation: 39
I'm trying to take several rows and collapse the values in one column into a comma-separated list so that I end up with 1 row.
I have this:
SELECT tc.dv_task,
lob.sys_id
FROM task_ci tc
INNER JOIN u_cmdb_ci_line_of_business lob on tc.ci_item = lob.sys_id
WHERE tc.dv_task = 'INC1157655'
The output is several rows, all have the same INC#, but different sys ids.
I need the output to be one row, where first column is INC# and second column is a list of sys ids. Like this:
INC1157655
42cd17e713cd660000c0fc04e144b0f5, a6cd57e713cd660000c0fc04e144b038, 35ddd7e713cd660000c0fc04e144b074, etc
I tried STRING_AGG but got an error that that isn't a recognized function.
Any help appreciated.
Thanks, Chrissy
Upvotes: 0
Views: 41