문제/SQL

231018 복습 겸 문제

잇꼬 2023. 10. 18. 17:26
728x90
반응형
SMALL

[문제1] SELECT 문을 이용해서 1~100 출력해주세요.

SELECT level
FROM dual
CONNECT BY level <= 100;


[문제2] SELECT 문을 이용해서 2단을 출력해주세요

SELECT '2 x '||level||' = '||2*level "2단"
FROM dual
CONNECT BY level <= 9;



[문제3] SELECT 문을 이용해서 2단~9단 까지 출력해주세요.
# DAN

SELECT LEVEL+1 DAN
FROM DUAL
CONNECT BY LEVEL <= 8;

# NUM

SELECT LEVEL NUM
FROM dual
CONNECT BY LEVEL <= 9;


# 결합

SELECT * 
FROM ( SELECT LEVEL+1 dan
       FROM dual
       CONNECT BY LEVEL <= 8),
     ( SELECT LEVEL NUM
       FROM dual
       CONNECT BY LEVEL <= 9);


# 구구단 출력

SELECT dan||' * '||num||' = '||dan*num 구구단
FROM ( SELECT LEVEL+1 dan
       FROM dual
       CONNECT BY LEVEL <= 8),
     ( SELECT LEVEL num
       FROM dual
       CONNECT BY LEVEL <= 9);

728x90
반응형
LIST