SQL 기초 실무/SQL 알고리즘 문제

23.09.29. SQL Developer 알고리즘 문제 ⑨

잇꼬 2023. 10. 4. 11:02
728x90
반응형
SMALL

9. 1부터 10까지 짝수만 출력

-- 예제118. 1부터 10 까지 짝수만 출력. 
select deptno, listagg(ename, ', ') within group ( order by ename asc )
    from emp 
    group by deptno ;

select listagg(ename, ', ') within group ( order by ename asc)
    from emp ;

select listagg(ename, ', ')
    from emp ; 

select listagg(level, ', ') as 짝수
    from dual 
    where mod(level, 2) = 0 
    connect by level <= 10 ;

undefine p_n
accept p_n prompt '숫자를 입력하세요.' ;

select listagg(level, ', ') as 짝수
    from dual 
    where mod(level, 2) = 0 
    connect by level <= &p_n ;
    
-- 문제1. 1부터 10까지 홀수만 가로로 출력하세요. 
select listagg(level, ', ') as 홀수 
    from dual 
    where mod(level, 2) = 1
    connect by level  <= 10 ;
728x90
반응형
LIST