Saturday, January 12, 2013

SQL to concatenate column values from multiple rows

There are a few ways depending on what version you have
SELECT pid, LISTAGG(Desc, ' ') WITHIN GROUP (ORDER BY seq) AS desc
FROM   B
GROUP BY pid;
Then join to A to pick out the pids you want.

No comments:

Post a Comment