I need to concatenate the rows(taille). for example, for the code_commande 001 and code_article=1, I need to concatenate in list all taille which have these two conditions. another example, for code_commande=001 and code_article=2, the same job I need to concatenate in a list all taille which have these two conditions. this for all
code_commande code_article taille 001 1 s 001 1 m 001 1 xl 001 1 x52 001 2 m 001 1 5566 001 2 x52 001 1 xl 002 1 s 002 2 m 001 3 xxl 002 3 xs 001 1 ml 001 1 xs32
I need to concatenate taille for each code_commande for each code_article example of result:
001 1 s,m,xl etcc
dynamically
I should have a table who grouped the ( taille) for each code_commande for each code_article like:
001 1 s,m,xl, 001 2 s,xl,l 002 1 xs,ettcc
I have tried this query but ,it concatenate all (taille) for all rows the query
Select [code_commande],[code_article], SUBSTRING(
(
SELECT ',' +[taille] AS 'data()'
FROM [dbo].[commande] FOR XML PATH('')
), 2 , 9999) As taille_commande
from [dbo].[commande]
order by [code_article],[code_commande]desc