Recursive CTE 개념
Recursive CTE (Common Table Expression)는 CTE 중 자기 자신을 반복적으로 호출하는 CTE이다.
with recursive temp as
(
select 0 as trans_cnt
from transactions
union
select trans_cnt+1
from temp
where trans_cnt < (
select count(*)
from transactions
group by user_id, transaction_date
order by 1 desc limit 1)
)
'언어 꿀Tip > SQL' 카테고리의 다른 글
10_05. Difference between timestamp (날짜,시간 차이 구하기) (0) | 2021.07.01 |
---|---|
10_04. 연속적인 log_id에 대한 시작, 끝 log_id 구해라 (Find the Start and End Number of Continuous Ranges) (0) | 2021.06.30 |
10_02. [mysql] moving average & rolling sum (0) | 2021.06.30 |
10_01. PERCENT_RANK() 와 CUME_DIST() 함수 (0) | 2021.06.18 |