Thanks for the response. I had tried that. Do you get it to work?
I get:
ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
Which makes sense, but adding it alters my results.
Try creating a CTE which gets distinct data first, then reference the cte when building up the string