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
add
group task_name
outer select working.in inner select use
where
filter records task_name outer select.
some time ago, learned this example.
Comments
Post a Comment