На всякий случай, если вы хотите попробовать подход PIVOT
.
Пример
Select *
From (
Select WEARER
,SKU
,Col = concat('SKU ',row_number() over (partition by wearer order by SKU) )
from YourTable
) src
Pivot (max(SKU) for Col in ([SKU 1],[SKU 2],[SKU 3],[SKU 4],[SKU 5] ) ) pvt
Возвращает
WEARER SKU 1 SKU 2 SKU 3 SKU 4 SKU 5
Wearer 1 SKU 38 NULL NULL NULL NULL
Wearer 2 SKU 47 SKU 75 NULL NULL NULL
Wearer 3 SKU 38 NULL NULL NULL NULL
Wearer 7 SKU 47 SKU 99 NULL NULL NULL
РЕДАКТИРОВАТЬ - Если вам не нужны значения NULL
Select WEARER
,[SKU 1] = concat('',[1])
,[SKU 2] = concat('',[2])
,[SKU 3] = concat('',[3])
,[SKU 4] = concat('',[4])
,[SKU 5] = concat('',[5])
From (
Select WEARER
,SKU
,Col = row_number() over (partition by wearer order by SKU)
from YourTable
) src
Pivot (max(SKU) for Col in ([1],[2],[3],[4],[5] ) ) pvt