See title. Basically, the data in this report is set up such that each value in Field A has multiple corresponding values in Field B, and I need to display Field B as a comma-se
Here is my structure:
CREATE TABLE [dbo].[Regional](
[State] [char](20) NULL,
[Region] [char](10) NULL,
[County] [char](20) NULL
)
Here is my query:
SELECT state,
region,
(SELECT Rtrim(county) + ','
FROM regional b
WHERE a.state = b.state
AND a.region = b.region
FOR XML PATH('')) counties,
Count(*) countycount
FROM regional a
GROUP BY state,
region
Here is the output:
state region counties countycount
AL South Mobile,Baldwin, 2
MS South Jackson,Harrison,Stone, 3
You will notice a trailing ',' that you will need to trim. That should be simple if your displaying this in SSRS.