Concatenate query output

31 Views Asked by At

I have two tables one containing the details of the user and another containing the details of user's tasks. I need to return one row for each user containing the username and the task ids. The query I have is as follows

select 
    w.user
    , (select '; ' +taskid from tasks d where d.guid = w.guid  FOR XML PATH(''))
from taskuser w
where w.type = 'pm0'
group by w.user, w.tid

The output I am getting is

username TaskId
Frane PM0-10003
Jordan PM0-10004
Jordan PM0-10005
Jordan PM0-10006

What I want is

Username TaskId
Frane PM0-10003
Jordan PM0-10004, PM0-10005, PM0-10006
0

There are 0 best solutions below