Hi @Ali Yılmaz ,
Welcome to the microsoft TSQL Q&A forum!
Because the OrderId corresponding to ID=1 and ID=2 are both 1, redundant results will be returned. A simple modification based on the ErlandSommarskog code can return the answer you want:
SELECT O.ID, substring(orderdata, 1, len(orderdata) - 2)
FROM [Order] O
CROSS APPLY (SELECT concat(P.Name, ' Size: ', PS.Size, ' Quantity: ', oi.Quantity)
FROM OrderItem oi
JOIN Product P ON oi.ProductID = P.ID
JOIN ProductCombination PC ON oi.ProductID = PC.ProductId
JOIN ProductSize PS ON PC.AttributeId = PS.ProductCombinationId
WHERE oi.Id = 1
FOR XML PATH('')) AS od(orderdata)
If you have any question, please feel free to let me know.
Regards
Echo
Note: Please follow the steps in our [documentation][3] to enable e-mail notifications if you want to receive the related email notification for this thread.