with recursive
with recursvie
--with recursive int_range(A)
with recursive int_range(hour) as (
select 0
union
select int_range.hour + 1 from int_range where int_range.hour < 3
)
select * from int_range;
--with recursive int_range
with recursive int_range as (
select 0 as hour
union
select int_range.hour + 1 from int_range where int_range.hour < 3
)
select * from int_range;
--필드가 2개 이상일 경우
--with recursive int_range(A, B)
with recursive int_range(hour, min) as (
select 0, 11
union
select int_range.hour + 1, int_range.min from int_range where int_range.hour < 3
)
select * from int_range;
--with recursive int_range
with recursive int_range as (
select 0 as hour, 11 as min
union
select int_range.hour + 1, int_range.min from int_range where int_range.hour < 3
)
select * from int_range;
--with recursive int_range(A)
1. 처음에 0 을 select 한다.
2. 그리고 where 절 조건에 맞을 때까지 1씩 늘린 값을 select 한다.
3. 최종적으로 0, 1, 2가 조회된다.
'SQL > 프로그래머스' 카테고리의 다른 글
[프로그래머스] Level2) NULL 처리하기 (0) | 2021.12.21 |
---|---|
[프로그래머스] Level1) 이름이 있는 동물의 아이디 (0) | 2021.12.18 |
[프로그래머스] Level1) 이름이 없는 동물의 아이디 (0) | 2021.12.18 |
[프로그래머스] Level4) 입양 시각 구하기(2) (0) | 2021.12.17 |