I have the following code, I want to transpose multiple rows to one column.
This is an example of how my data looks like:
DocNum ItemCode Item Name
-----------------------------------
40008 100208 Desc of 100208 /*parts*/
40008 100209 Desc of 100208 /*parts*/
40008 200845 Desc of 200845 /* tire*/
40008 320361 Desc of 320361 /* disc*/
40008 400511 Desc of 400511 /* rim*/
I am looking a result as shown below
itemcode rim/disc tire/parts
------------------------------------------------
40008 400511-Desc of 400511 200845-Desc of 200845
320361-Desc of 320361 100208-Desc of 100208
100209-Desc of 100208
This is the SQL code I tried:
select top 10
T0.[DocNum], T0.[OriginNum], T0.[ItemCode], T0.[ProdName],
T2.[CardName], T0.[Status], T4.[U_Routing], T0.[PlannedQty],
T0.[CmpltQty], T0.[PostDate], T0.[DueDate],T1.[ItemCode],
T3.[ItemName], T0.[U_Work_Center], T0.[CreateDate]
from
[SERVERNAME]..[DATABASE].[OWOR] as T0
inner join
[SERVERNAME]..[DATABASE].[WOR1] T1 on T0.[DocEntry] = T1.[DocEntry]
inner join
[SERVERNAME]..[DATABASE].[OCRD] T2 on T0.[CardCode] = T2.[CardCode]
inner join
[SERVERNAME]..[DATABASE].[OITM] T3 on T1.[ItemCode] = T3.[ItemCode]
inner join
[SERVERNAME]..[DATABASE]. [OITM] T4 on T0.[ItemCode] = T4.[ItemCode]