SELECT MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 1, num)) no1,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 2, num)) no2,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 3, num)) no3,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 4, num)) no4,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 5, num)) no5,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 6, num)) no6
FROM (
SELECT grp, num
FROM (
SELECT grp, num, MOD(ROWNUM - 1, 45) + 1 rnum
FROM (
SELECT CEIL(LEVEL / 45) grp, MOD(LEVEL - 1, 45) + 1 num
FROM DUAL
CONNECT BY LEVEL <= 45 * 2
ORDER BY 1, DBMS_RANDOM.VALUE
)
)
WHERE rnum <= 6
ORDER BY grp, num
)
GROUP BY grp
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 2, num)) no2,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 3, num)) no3,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 4, num)) no4,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 5, num)) no5,
MIN(DECODE(MOD(ROWNUM - 1, 6) + 1, 6, num)) no6
FROM (
SELECT grp, num
FROM (
SELECT grp, num, MOD(ROWNUM - 1, 45) + 1 rnum
FROM (
SELECT CEIL(LEVEL / 45) grp, MOD(LEVEL - 1, 45) + 1 num
FROM DUAL
CONNECT BY LEVEL <= 45 * 2
ORDER BY 1, DBMS_RANDOM.VALUE
)
)
WHERE rnum <= 6
ORDER BY grp, num
)
GROUP BY grp
'DataBase > Oracle' 카테고리의 다른 글
오라클에서 디비링크걸기 (0) | 2010.05.11 |
---|---|
[펌]오라클 시간 연산 (0) | 2010.03.05 |
[펌]오라클에서 파티션 테이블 사용 (0) | 2010.01.05 |
파티션 테이블 삭제 (0) | 2010.01.05 |
[펌]오라클 힌트2 (0) | 2009.12.30 |