 <p>I don't think <code>pivot</code> is useful here. Try this</p> <pre><code>WITH cte1 AS (SELECT Row_number()OVER(ORDER BY Id) RN, value AS Data1 FROM yourtable WHERE col_id = 1), cte2 AS (SELECT Row_number()OVER(ORDER BY Id) RN, value AS Data2 FROM yourtable WHERE col_id = 2), cte3 AS (SELECT Row_number()OVER(ORDER BY Id) RN, value AS Data3 FROM yourtable WHERE col_id = 3) SELECT Row_number()OVER(ORDER BY a.rn) AS serial, Data1, Data2, Data3 FROM cte1 A FULL OUTER JOIN cte2 B ON a.RN = b.RN FULL OUTER JOIN cte3 C ON b.RN = C.RN </code></pre>