데이터분석캠프 TIL
250228 데이터분석캠프 TIL
selenaass
2025. 2. 28. 22:11
1. 회고
오늘 하루 최종플젝을 진행하기 위해, 팀원을 찾으러 다녔다. 포폴 작업을 하느라 거의 다른 것들은 못한 것 같다.
2. QCC
with ranked_events as (select customer_id,
event_type,
event_date,
case
when event_type = 'JOIN' THEN 'ACTIVE'
WHEN event_type = 'WITHDRAW' THEN 'INACTIVE'
end as status,
event_date as start_date,
lead(event_date) over (partition by customer_id order by event_date) as next_event
from membership_history mh)
select customer_id,
status,
start_date,
date_sub(next_event, interval 1 day) as end_date,
case
when status = 'ACTIVE' and next_event is null then 1
end as current_flag
from ranked_events
order by customer_id, start_date;