Maybe something like this:
WITH SampleData AS(
SELECT 1 n UNION ALL
SELECT 2 n UNION ALL
SELECT 3 n UNION ALL
SELECT 4 n UNION ALL
SELECT 5 n UNION ALL
SELECT 6 n UNION ALL
SELECT 7 n UNION ALL
SELECT 8 n UNION ALL
SELECT 9 n
)
SELECT MAX(CASE WHEN n % 3 = 1 THEN n END) col1,
MAX(CASE WHEN n % 3 = 2 THEN n END) col2,
MAX(CASE WHEN n % 3 = 0 THEN n END) col3
FROM SampleData
GROUP BY (n - 1) / 3
Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?
How to post data/code on a forum to get the best help: Option 1 / Option 2