SQL> SELECT CEIL(ROWNUM/3), EMPNO FROM EMP;
CEIL(ROWNUM/3) EMPNO
-------------- ----------
1 7369
1 7499
1 7521
2 7566
2 7654
2 7698
3 7782
3 7788
3 7839
4 7844
4 7876
4 7900
5 7902
5 7934
5 1111
15 螳 給.
SQL> SELECT CEIL(ROWNUM/3) ID,
2 DECODE(MOD(ROWNUM,3), 1, EMPNO, NULL) NO1,
3 DECODE(MOD(ROWNUM,3), 2, EMPNO, NULL) NO2,
4 DECODE(MOD(ROWNUM,3), 0, EMPNO, NULL) NO3
5 FROM EMP;
ID NO1 NO2 NO3
---------- ---------- ---------- ----------
1 7369
1 7499
1 7521
2 7566
2 7654
2 7698
3 7782
3 7788
3 7839
4 7844
4 7876
4 7900
5 7902
5 7934
5 1111
15 螳 給.
SQL> -- CEIL(ROWNUM/3)襦 蠏碁9讌伎 蠏 蠏碁9伎 襾語 1,2,0 螻壱 MAX襯 豬
SQL> SELECT CEIL(ROWNUM/3) ID,
2 MAX(DECODE(MOD(ROWNUM, 3), 1, EMPNO, NULL)) EMPNO1,
3 MAX(DECODE(MOD(ROWNUM, 3), 2, EMPNO, NULL)) EMPNO2,
4 MAX(DECODE(MOD(ROWNUM, 3), 0, EMPNO, NULL)) EMPNO3
5 FROM EMP
6 GROUP BY CEIL(ROWNUM/3);
ID EMPNO1 EMPNO2 EMPNO3
---------- ---------- ---------- ----------
1 7369 7499 7521
2 7566 7654 7698
3 7782 7788 7839
4 7844 7876 7900
5 7902 7934 1111
SQL>