I have a mapping table structured similarly to the following:

ID       EntityID   EntityName  EntityCategory   ValueID
 1          1       System      Category1        50
 2          1       System      Category1        51
 3          1       System      Category1        52
 4          1       System      Category1        53

where ValueID is a FK to another table:

ID     Value
50     Red
51     Blue
52     Green
53     Yellow 

I need to output a report for business users where each row in the report represents one primary-keyed row in this table, but the "Value" column is a flattened concatenation of the values related to ValueID, like this:

Name     Category    Possible Values
System   Category1   Red | Blue | Green | Yellow

How can I write a query to produce this "flattened" output?



Browse other questions tagged or ask your own question.