WITH cart AS (
SELECT product_id,
user_id,
COUNT(*) AS cart_count
FROM team.vvip_전체_데이터 v전데
WHERE event_type = 'cart'
GROUP BY product_id, user_id
),
purchase AS (
SELECT product_id,
user_id,
COUNT(*) AS purchase_count
FROM team.vvip_전체_데이터 v전데
WHERE event_type = 'purchase'
GROUP BY product_id, user_id
)
SELECT
COUNT(DISTINCT c.product_id) AS total_cart,
COUNT(DISTINCT p.product_id) AS total_purchase,
1-(COUNT(DISTINCT p.product_id) / COUNT(DISTINCT c.product_id)) AS cart_abandonment_rate
FROM cart c
LEFT JOIN purchase p
ON c.product_id = p.product_id AND c.user_id = p.user_id;

이거 수정하느라고 또 고생했다🥲
WITH month5 AS(SELECT user_id, product_id, event_type FROM team.`2019_oct` o
UNION ALL
SELECT user_id, product_id, event_type FROM team.`2019_nov` n
UNION ALL
SELECT user_id, product_id, event_type FROM team.`2019_dec` d
UNION ALL
SELECT user_id, product_id, event_type FROM team.`2020_jan` j
UNION ALL
SELECT user_id, product_id, event_type FROM team.`2020_feb` f
),
cart AS (
SELECT product_id,
user_id,
COUNT(*) AS cart_count
FROM month5
WHERE event_type = 'cart'
GROUP BY product_id, user_id
),
purchase AS (
SELECT product_id,
user_id,
COUNT(*) AS purchase_count
FROM month5
WHERE event_type = 'purchase'
GROUP BY product_id, user_id
)
SELECT
COUNT(DISTINCT c.product_id) AS total_cart,
COUNT(DISTINCT p.product_id) AS total_purchase,
1-(COUNT(DISTINCT p.product_id) / COUNT(DISTINCT c.product_id)) AS cart_abandonment_rate
FROM cart c
LEFT JOIN purchase p
ON c.product_id = p.product_id AND c.user_id = p.user_id;
결론적으로는 또 .... 아무고토 못했음

VIP 테이블 내에서 카트 월별 제거 수

일별 전환율 비교
근데 뭔가 유의미한 건 카트 월별 제거 수인것 같아서 이건 쓰기로 킵킵
내일은 그래도 마지막 정리까지 가능할 것 같다리
엉엉엉엉
SQL - 나이가 없는 회원 정보 구하기
SQL - 가장 비싼 상품 구하기
오늘 한 건 기초분석 밖에 없어서 체크표시 할 힘이 안나고요🥲 코드카타 두 개밖에 못 풀었다 지각도 함 미친 세상아 .......... 내일 무사히 잘 보내고 싶다 엉엉 엉 엉 엉