1

Closed

Concatinate distinct values

description

There should be a way of saying that you only need the distinct values to be concatenated.

For example in a group you may have multiple values that are duplicate and you might only need the list of values that are distinct.
Closed Sep 18, 2014 at 4:55 AM by opcthree

comments

opcthree wrote Jul 17, 2014 at 4:32 AM

Unless I am misunderstanding your request, the Aggregate Function does not need to be modified. We can prevent duplicates in the resulting list by supplying DISTINCT in the query to limit the values that are passed into the Aggregate Function, like this, from the demo script:
SELECT  DocID,
        dbo.GROUP_CONCAT(DISTINCT ErrorDetail) AS FieldTypeDetail
FROM    dbo.GroupConcatTestData
GROUP BY DocID
ORDER BY DocID;

wrote Sep 18, 2014 at 4:55 AM