I got introduced to SSRS recently and I am facing a problem in extracting data from the database. I searched online and I found out that this is called concatenate text from multiable rows. Now, I tried a code.. but in the results, it give me the data duplicated next to each other separated by a comma. Now I am happy that it is separating the result with a coma... but why giving me the data duplicated?
The Code:
select distinct wm1.Date, p1.[Medical Record Number], Wound_Type =CONCAT
((
select distinct CAST(wt2.Name as VARCHAR(MAX))+ ' /// ' from dbo.[Wound Type] as wt2
inner join dbo.[Wound Management] as wm2 on wm2.[Wound Type_ID] = wt2.ID
inner join dbo.Patient as p2 on wm2.[Owner (Patient)_Patient_ID]=p2.ID
where wm1.Date=wm2.Date
FOR XML PATH('')
),wt1.Name)
from dbo.[Wound Type] as wt1
inner join dbo.[Wound Management] as wm1 on wm1.[Wound Type_ID] = wt1.ID
inner join dbo.Patient as p1 on wm1.[Owner (Patient)_Patient_ID]=p1.ID
group by wm1.Date, wt1.Name, p1.[Medical Record Number]
the result:
Please Help.