My SQL table is like following
City_Code Post_Code Post_Code_Description
100 A1 ABC
100 C8 XYZ
100 Z
try this:
select city_code,substring((select ',' + post_code
from city b where a.city_code=b.city_code
for xml path('')
),2,100)as post_code,
substring((select ',' + post_code_description
from city c where a.city_code=c.city_code
for xml path('')
),2,100)as post_code_description
from city a
group by a.city_code