I'm tryng to concatenate the differents 'Z' values from this query.. This is working but its too slow, my table has 1M records.
Any idea how to make this performant?
SELECT distinct A,B,C,D,E,F,G
,(ISNULL(STUFF((SELECT distinct ',' + RTRIM(Z)
from DBO.TABLA a
WHERE Z is not null and a.A = A
and B = a.B and C = a.C
and D = a.D and E = a.E
and F = a.F and G = a.G
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '')
, ''))
as blabla
No comments:
Post a Comment