Zde je A způsob, jak to udělat (funguje také s 2005):
Tabulka
DECLARE @table TABLE ( [Typ_ID] INT, [Client_ID] VARCHAR(50), [PBX_Vendor] VARCHAR(50) )
Data
vložte do @Table Select 127, '090820006311404926326C', 'AASTRA' Union All Select 127, '090820006311404926326C', 'Ericsson' Union All Select 127, '111012237401404926326C' 120209287521404926326C', 'Aastra' UNION ALL SELECT 127, '120209287521404926326C', 'Alcatel'
Dotaz
SELECT [ID_typu], [ID_klienta], ( SELECT STUFF(( SELECT ',' + [Vendor_PBX] FROM @table WHERE [ID_klienta] =tbl.[ID_klienta] AND [ID_typu] =tbl.[ID_typu ] GROUP BY [PBX_Vendor] ORDER BY [PBX_Vendor] FOR XML PATH('') ), 1, 1, '') ) PBX_VendorFROM @table tblGROUP BY [Type_ID], [Client_ID]
Výsledek
Typ_ID Client_ID PBX_Vendor127 090820006311404926326C Aastra,Ericsson127 111012237401404926326C Aastra127 1202020928926tel12020928926tel