you can try pivot. in my example here i have concatenated part and location together because i have no idea how to do this with two columns. the point that this is not good style remains, but maybe this helps you out a little.
i named your table ttt in my example:
select 'serialno' as serialno
, [1], [2], [3], [4], [5]
from
( select ROW_NUMBER() over (partition by serialno order by part + ' - ' + location) as rn
, serialno
, (part + ' - ' + location) as pl
from ttt ) as sourcetable
pivot (
max(pl)
for rn in ([1], [2], [3], [4], [5])
) as pivottable
as you can see there i only provided five slots. you can add more if you like, but there will always be a fixed amount of them
0
solved SQL, same column different rows to same row different columns [closed]