Pls, let me know if is possible to create this kind of query. I never saw something like that
Pls, check below the image. It´s exactly what I need to do!
Pls, let me know if is possible to create this kind of query. I never saw something like that
Pls, check below the image. It´s exactly what I need to do!
select
A.OrderID,
A.CustomerID,
stuff(
(select ' ' + T.Product
from test as T
where T.OrderID = A.OrderID and T.CustomerID = A.CustomerID
for xml path(''), type
).value('.', 'nvarchar(max)')
, 1, 1, '') as Product
from test as A
group by A.OrderID, A.CustomerID
If you have Product names in other table:
select
A.OrderID,
A.CustomerID,
stuff(
(select ' ' + P.Name
from test as T
inner join Products as P on P.ID = T.ProductID
where T.OrderID = A.OrderID and T.CustomerID = A.CustomerID
for xml path(''), type
).value('.', 'nvarchar(max)')
, 1, 1, '') as Product
from test as A
group by A.OrderID, A.CustomerID