시나리오 1 유저 퍼널 분석 (가입 → play → upgrade → cancel)

배경: 가입한 유저가 실제로 앱을 쓰고, 유료로 전환되고, 혹은 이탈하는 각 단계를 숫자로 확인합니다.


Step 1. 각 단계 유저 수 확인하기

목표: 퍼널 각 단계에 몇 명이 있는지 하나씩 조회해보기

-- 전체 가입자 수
SELECT COUNT(*) AS 가입자수 FROM users;

-- 앱을 실행한 유저 수 (play)
SELECT COUNT(DISTINCT user_id) AS play_유저수
FROM user_events
WHERE event_type = 'play';

-- 유료 전환한 유저 수 (upgrade)
SELECT COUNT(DISTINCT user_id) AS upgrade_유저수
FROM user_events
WHERE event_type = 'upgrade';

-- 이탈한 유저 수 (cancel)
SELECT COUNT(DISTINCT user_id) AS cancel_유저수
FROM user_events
WHERE event_type = 'cancel';

image.png

image.png

image.png

image.png

Step 2. 한 번에 모아서 보기

목표: 위에서 따로 조회한 내용을 한 쿼리로 합치기

SELECT
    event_type,
    COUNT(DISTINCT user_id) AS user_count
FROM user_events
WHERE event_type IN ('play', 'upgrade', 'cancel')
GROUP BY event_type
ORDER BY FIELD(event_type, 'play', 'upgrade', 'cancel');

image.png

image.png

Step 3. 채널별로 쪼개서 보기

목표: 어떤 채널에서 온 유저가 upgrade를 많이 하고, 어디서 cancel이 많은지 확인

SELECT
    u.signup_channel,
    COUNT(DISTINCT u.user_id ) AS total_users,
    COUNT(DISTINCT CASE WHEN e.event_type='upgrade' then 1 end) AS upgrade_users,
    COUNT(DISTINCT CASE WHEN e.event_type='cancel' then 1 end) AS cancel_user
FROM users u
LEFT JOIN user_events e ON u.user_id = e.user_id
GROUP BY u.signup_channel
ORDER BY upgrade_users DESC;