• 카테고리

    질문 & 답변
  • 세부 분야

    데이터 분석

  • 해결 여부

    미해결

DAU, WAU, MAU를 SQL로 구하기-02 관련 질문드립니다.

23.01.29 21:44 작성 23.01.29 22:30 수정 조회수 996

0

with

temp_00 as (

select generate_series('2016-08-02'::date, '2016-11-01'::date, '1 days'::interval)::date as current_date

)

select b.current_date, count(distinct user_id) as dau

from ga_sess a

cross join temp_00 b

where visit_stime >= (b.current_date - interval '1 days') and visit_stime < b.current_date

group by b.current_date

 

위 SQL문에서

where visit_stime >= (b.current_date - interval '1 days') and visit_stime < b.current_date

이 부분이 이해가 가지 않습니다.

current_date가 2016-08-02일 경우

visit_stime이 2016-08-02보다는 작아야 하고,

2016-08-01보다는 크거나 같다는 말인데..

그럼 즉, 2016-08-01 00:00:00 ~2016-08-01 23:59:59 라는 건데요..

그럼 이게 2016-08-01의 DAU가 아닌가요?..

select 절에서는 current_date로 group by를 해서

추출된 데이터는 2016-08-02의 DAU로 추출이 되더라구요..

실제 csv파일로 받아서 보아도,

2016-08-01의 dau가 1569로 확인이 되는거 같기두 하구요..

 

with

temp_00 as (

select generate_series('2016-08-01'::date, '2016-11-01'::date, '1 days'::interval)::date as current_date

)

select b.current_date, count(distinct user_id) as dau

from ga_sess a

cross join temp_00 b

where visit_stime >= b.current_date and visit_stime < (b.current_date + interval '1 days')

group by b.current_date

 

with

temp_00 as (

select generate_series('2016-08-01'::date, '2016-11-01'::date, '1 days'::interval)::date as current_date

)

select b.current_date, count(distinct user_id) as wau

from ga_sess a

cross join temp_00 b

where visit_stime >= (b.current_date - interval '6 days') and visit_stime < (b.current_date + interval '1 days')

group by b.current_date;

 

with

temp_00 as (

select generate_series('2016-08-01'::date, '2016-11-01'::date, '1 days'::interval)::date as current_date

)

select b.current_date, count(distinct user_id) as mau

from ga_sess a

cross join temp_00 b

where visit_stime >= (b.current_date - interval '29 days') and visit_stime < (b.current_date + interval '1 days')

group by b.current_date;

 

이렇게 구하는게 맞는거 아닌지 문의드립니다 !

 

 

 

답변 1

답변을 작성해보세요.

0

안녕하십니까,

(DAU 강의에서도 말씀 드리고 있지만), 여기서 Current Date는 DAU의 대상 기간이 아니라 DAU를 계산시작하는 시점 일자입니다.

그러니까, 오늘 만약에 DAU를 계산한다면 오늘 웹접속에 대한 Active User 갯수를 계산하는게 아니라 어제 일자의 Active User 갯수를 계산하는 것입니다.

DAU 계산을 하려면 일단 해당 일자가 지나야 합니다. 그래야 온전한 하루동안의 Active User를 계산할 수 있습니다. 그래서 current_date가 8/2이라면 8/1 00:00:00 ~ 23:59:59 까지의 접속 건수를 계산해야 합니다.

말씀하신대로 2016-08-01 00:00:00 ~2016-08-01 23:59:59는 2016-08-01의 접속에 대한 DAU 이지만 이걸 계산 시작한 일자는 8/2 이 되어야 하고 이게 current_date에 해당하는 것입니다. 회사별로 차이는 있을수 있지만 보통 8/2에 보는 DAU는 8/1 접속에 대한 DAU입니다.

 

감사합니다.

cis3093님의 프로필

cis3093

질문자

2023.01.30

안녕하세요, 선생님

답변 남겨주셔서 감사합니다 !

제가 DAU에 대한 정의를 잘못 이해하고 있었던거네요.

DAU는 전일에 대한 엑티브 유저였군요..

감사합니다 !

채널톡 아이콘