sql server - using stuff for fullname when task is same for two person even though fullname is not separating with comma -


select distinct    stuff((select distinct ', ' + u1.fullname      tm_user u1      u.tm_userid=u1.tm_userid          xml path ('')    ), 1, 2, '') fullname,  task_name project  join task                 on project.project_id=task.project_id           join timesheet                  on timesheet.task_id=task.task_id           join team                 on project.project_id = team.project_id           join tm_user u                 on u.tm_userid=timesheet.user_id  u.is_active=1  , u.report_to=13  ,  worked_dte between '2014-03-18' , '2014-03-21' 

output getting

 fullname                         task_name chandu devathi                       new task 2222 chandu devathi                       tesst eprom copy chandu devathi                       testing plz ignore. harish kumar ramakrishnappa      tesst eprom copy 

excepted output

 fullname                                                   task_name chandu devathi                                                 new task 2222 chandu devathi,harish kumar ramakrishnapp                     tesst eprom copy chandu devathi                                                testing plz ignore. 

you should

  1. add group task_name outer select working.

  2. in inner select use where filter records task_name outer select.

some time ago, learned this example.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -