| Author |
Topic  |
|
|
Ciupaz
Posting Yak Master
Italy
176 Posts |
Posted - 11/23/2012 : 08:49:37
|
Hello all, I have a query that returns me these values:
Plant UP BRINDISI BR1 BRINDISI BR3 BRINDISI BR3 BRINDISI BR4 PIACENZA PZ1 S.FILIPPO SF3 BRINDISI BRTest BRINDISI BR-FV PIACENZA PZ4
I have intead to get this result:
BRINDISI BR1,BR2,BR3,BR4,BRTest,BR-FV PIACENZA PZ1,PZ4 S.FILIPPO SF3
grouped by "Plant" field e in the second field a concatenatio of UP collegated..
How can I obtain this?
Thanks in advance.
Luigi |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1451 Posts |
Posted - 11/23/2012 : 08:56:55
|
Just replace red marked part with your table name
-- Get CSV values SELECT t.Plant, STUFF((SELECT ',' + s.UP FROM TestTable s WHERE s.plant = t.plant FOR XML PATH('')),1,1,'') AS CSV FROM TestTable AS t GROUP BY t.plant GO
-- Chandu |
 |
|
|
Ciupaz
Posting Yak Master
Italy
176 Posts |
Posted - 11/23/2012 : 09:17:09
|
Perfect, thank you very much Bandi. I never get this solution by myself.
Luigi |
 |
|
| |
Topic  |
|
|
|