Привет, если я понимаю, что вы пытаетесь сделать, я думаю, что этот пример может вам помочь:
CREATE TABLE #ClientResponse (ClientId int, ClientResponse varchar(50))
INSERT INTO #ClientResponse
SELECT 116,'M'
UNION ALL
SELECT 116,'M'
UNION ALL
SELECT 116,'N'
UNION ALL
SELECT 116,'J'
UNION ALL
SELECT 116,'G'
UNION ALL
SELECT 116,'M'
UNION ALL
SELECT 116,'K'
select 'ClientResponse' As Item,
[0],[1],[2],[3],[4],[5],[6],[7]
FROM (SELECT *, ROW_NUMBER() OVER(ORDER by ClientId) AS 'IndexResponse' FROM #ClientResponse) As SourceTable
PIVOT
(
MAX(ClientResponse)
FOR IndexResponse IN ([0], [1], [2], [3], [4],[5],[6],[7])
) AS PivotTable;
DROP TABLE #ClientResponse
РЕЗУЛЬТАТ:
