i need to get csv from a column but the minimum value from the rest of the columns (or any value because they are same for a group). As an example;
I have the following
Use STUFF
with GROUP BY
.
Query
SELECT STUFF((SELECT ',' + [COL1]
FROM [your_table_name]
WHERE ([COL2] = t.[COL2] AND [COL3] = t.[COL3] AND [COL4] = t.[COL4])
FOR XML PATH(''),TYPE).value('(./text())[1]','VARCHAR(MAX)')
,1,1,'') AS COL1, [COL2], [COL3], [COL4]
FROM [your_table_name] t
GROUP BY [COL2], [COL3], [COL4]