Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Group by XML PATH
with partitioned_data as
(
select dossier, dos from (
select dossier, ntile(50) over(order by dossier) as dos from [dbo].[input_legacy_excel]
) x
)
Select P.dos, SUBSTRING(STUFF(
(
SELECT ',' + dossier
FROM partitioned_data
where dos = p.dos
FOR XML PATH(''),TYPE).value('(./text())[1]', 'VARCHAR(MAX)'), 1,2,''
), 2, 999999) As dossiers
from partitioned_data p
group by p.dos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.