Приведенный ниже код помогает вам динамически Pivot N количество строк
DECLARE @DynamicCols VARCHAR(MAX);
CREATE TABLE #temp ([Date] DATE, [CallerANI] VARCHAR(MAX), [Skills] VARCHAR(MAX), [CallerDNIS] VARCHAR(MAX))
INSERT INTO #temp
VALUES ('2019-05-27','27315391449','loc-SPD-CSR-OverFlow','47515070001'),
('2019-05-27','27315391449','cc-Loc-Voice','Transfer'),
('2019-05-27','27315391449','cc-Loc-Voice-abc','SoMe')
SELECT * FROM #temp
SELECT @DynamicCols = STUFF([Cols],1,1,'') FROM (
SELECT [Cols] = (SELECT ',' + QUOTENAME([CallerDNIS]) FROM #temp A
FOR XML PATH('') ) ) A;
EXEC ('
SELECT [Date], [CallerANI], ' + @DynamicCols+'
FROM #temp
PIVOT
(
MAX([Skills])
FOR [CallerDNIS] in (' + @DynamicCols+')
) PIV');