inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Phân tích dữ liệu SQL được học qua nhiều ví dụ khác nhau

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

1256

cis3093

10 câu hỏi đã được viết

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;

 

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

 

 

 

DBMS/RDBMS dbms/rdbms sql postgresql 퍼포먼스-마케팅 데이터-엔지니어링 데이터 엔지니어링 퍼포먼스 마케팅

Câu trả lời 1

0

dooleyz3525

안녕하십니까,

(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입니다.

 

감사합니다.

0

cis3093

안녕하세요, 선생님

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

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

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

감사합니다 !

"주문별 고객별 연관 상품 추출 SQL로 구하기-02" 수업 질문

0

51

2

쿼리 질문있습니다!!

0

49

2

없는강의요청해도됩니까,,

0

89

2

아래와 동일한 질문에 대한 추가질문입니다

0

69

2

cnt/max로 구한 결과의 차이

0

100

2

쿼리에 대한 질문이 있습니다.

0

116

2

퍼널 질문드립니다.

0

112

1

ADSP자격증

0

281

2

특정 스키마에서 생성한 편집기의 쿼리를 판다스에 삽입하는 방법

0

161

1

백업파일 테이블 생성 오류

0

233

1

"사용자별 특정 상품 주문시 함께 가장 많이 주문된 다른 상품 추출하기"에서 조건관련..

0

161

1

Plotly을 이용해 treemap시각화시 공유사항

0

277

2

월단위 카테고리별 매출액과 주문건수 및 전체매출액 대비 비율 sql로 구하기 수업 중 질문이 있습니다.

0

247

1

with 절 질문

0

239

1

데이터 분석 SQL Fundamentals 강의 할인 문의

0

214

1

리텐션 구하는 방법 문의

0

215

1

캐글데이터 Postgresql 사용

0

352

2

mau 구할때 group by 사용안해도 count 집계함수가 왜 가능한지 모르겠습니다.

0

261

1

매출분석 1에서 partition by와 group by의 차이

0

355

1

postgres 설치 오류

0

316

1

맥 계정에서 postgres 접속 시 비밀번호 입력 실패현상

1

542

2

pandas 연계시 오류.....

0

1242

3

시각화 그래프가 안보여요

0

298

1

ntile 정규분포에 관하여 ... 향후 일을 하게 될 시

0

357

1