전체/Oracle
ORACLE WITH AS 사용방법
effortDev
2017. 7. 25. 18:13
ORACLE WITH AS 사용방법 - 1
1 2 3 4 5 6 7 8 9 10 11 | -- [WITH 구문 사용방법] WITH AA AS (SELECT ROWNUM, 'TEST1', SYSDATE FROM DUAL UNION ALL SELECT ROWNUM, 'TEST2', SYSDATE FROM DUAL UNION ALL SELECT ROWNUM, 'TEST3', SYSDATE FROM DUAL) SELECT * FROM AA; | cs |
출력 결과
ROWNUM | 'TEST1' | SYSDATE |
1 |
TEST1 |
2017-07-25 오후 6:14:08 |
1 |
TEST2 |
2017-07-25 오후 6:14:08 |
1 | TEST3 | 2017-07-25 오후 6:14:08 |
ORACLE WITH AS 사용방법 - 2
1 2 3 4 5 6 7 8 9 10 11 12 13 | -- [WITH 구문(2개 SUB쿼리) 사용방법] WITH AA AS (SELECT ROWNUM AS SEQ , 'TEST1' AS NAME , SYSDATE FROM DUAL), BB AS (SELECT ROWNUM AS SEQ , 'TEST2' AS NAME , SYSDATE FROM DUAL) SELECT * FROM AA, BB WHERE AA.SEQ = BB.SEQ | cs |
출력 결과
SEQ |
NAME |
SYSDATE |
SEQ_1 |
NAME_1 |
SYSDATE_1 |
1 |
TEST1 |
2017-07-25 오후 6:16:53 |
1 |
TEST2 |
2017-07-25 오후 6:16:53 |