Используйте PIVOT
:
SELECT A, B, C, D
FROM (
SELECT value,
MOD( ROWNUM - 1, 4 ) AS col,
CEIL( ROWNUM / 4 ) AS rn
FROM table_name
)
PIVOT( MAX( value ) FOR col IN (
0 AS A,
1 AS B,
2 AS C,
3 AS D
) )
ORDER BY rn;
Так что, если ваши данные:
CREATE TABLE table_name ( value ) AS
SELECT ROUND(DBMS_RANDOM.VALUE(1,1000))
FROM DUAL
CONNECT BY LEVEL <= 25;
, то выдается:
A | B | C | D
--: | ---: | ---: | ---:
754 | 622 | 265 | 181
566 | 801 | 844 | 320
938 | 377 | 919 | 306
921 | 402 | 737 | 143
562 | 94 | 868 | 790
617 | 809 | 437 | 469
264 | <em>null</em> | <em>null</em> | <em>null</em>
дБ <> скрипка здесь