묻고 답해요
160만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
- 
      
        
    미해결다양한 사례로 익히는 SQL 데이터 분석
'작년 대비 동월 매출 비교 SQL로 구하기' 문의 드립니다.
작년 대비 동월 매출 비교 SQL로 구하기 부분에서lag 함수로 12 row 이전의 데이터를 가져오셨는데,실제 데이터가 특정 월에 매출이 발생하지 않는 케이스를 포함할 경우에는 어떻게 해야할지 문의 드립니다.
 - 
      
        
    미해결마케터를 위한 구글 애널리틱스 실무
강의북 요청
안녕하세요! 강의북 pdf 파일로 요청드립니다! jpejhp@gmail.com
 - 
      
        
    미해결다양한 사례로 익히는 SQL 데이터 분석
DAU, WAU, MAU를 SQL로 구하기-02 관련 질문드립니다.
withtemp_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 daufrom ga_sess across join temp_00 bwhere visit_stime >= (b.current_date - interval '1 days') and visit_stime < b.current_dategroup 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로 확인이 되는거 같기두 하구요.. withtemp_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 daufrom ga_sess across join temp_00 bwhere visit_stime >= b.current_date and visit_stime < (b.current_date + interval '1 days')group by b.current_date withtemp_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 waufrom ga_sess across join temp_00 bwhere visit_stime >= (b.current_date - interval '6 days') and visit_stime < (b.current_date + interval '1 days')group by b.current_date; withtemp_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 maufrom ga_sess across join temp_00 bwhere visit_stime >= (b.current_date - interval '29 days') and visit_stime < (b.current_date + interval '1 days')group by b.current_date; 이렇게 구하는게 맞는거 아닌지 문의드립니다 !
 - 
      
        
    미해결[베스트셀러 저자 직강] 디지털 마케팅과 페이스북 / 인스타그램 광고
광고비 소진 질문
안녕하세요,트래픽/참여 등으로 광고 돌렸는데수치 변화가 아주 미미하고 광고비 소진이 거의 되지 않습니다.머신러닝 기간 중 변경을 너무 많이 해서 그런 걸까요?ㅠ이런 경우에는 차라리 광고 중지하고 다시 돌리는 것이 좋을지요....
 - 
      
        
    미해결다양한 사례로 익히는 SQL 데이터 분석
쿼리 질문
안녕하세요, 도움을 받고자 글 올립니다.97년 이후 nw데이터의 '국가/ 기준월 / 대표제품명 / 구매고객수 / 동시구매 고객 수 / 구매 횟수 / 동시구매 횟수 / 동시구매율' 을 구해보았는데 결과가 나오긴 하는데 맞는지 알 수가 없어서 코드리뷰 부탁드립니다. 더불어 더 좋은 코드가 있을지 여쭙습니다.새해 복 많이 받으세요 with uu as (select customer_id, product_id, order_id, product_name, order_date, ship_addressfrom(select c.product_id, c.product_name, a.amount, b.order_date, b.ship_address , b.customer_id, b.order_idfrom order_items a join orders b on a.order_id = b.order_idjoin products c on a.product_id = c.product_idwhere extract(year from b.order_date) >= 1997) tt), xx as (select ww.customer_id, ww.product_id as prd_01, vv.product_id as prd_02, ww.order_date, ww.ship_addressfrom uu ww join uu vv on ww.customer_id = vv.customer_id), temp_01 as (select customer_id, prd_01, prd_02, extract(year from order_date) as year_ord, extract(month from order_date) as month_ord, ship_address as countryfrom xxwhere prd_01 != prd_02group by 1,2,3,4,5,6order by 1,2,3,4,5,6)---------------구매자 id, 대표제품 id, 동시구매제품 id, 년, 월, 국가, temp_03 as (select prd_01, prd_02, count(*) as cnt_prd_prdfrom temp_01group by 1,2order by 1, 3 desc) -----------------대표제품 id, 동시구매제품 id, 동시구매 횟수, temp_04 as (select distinct product_id, count(customer_id) as cnt_prdfrom order_items oi join orders o on oi.order_id = o.order_idgroup by 1order by 1)-------------------- 대표제품 id, 구매고객수, temp_05 as (select prd_01, prd_02, count(customer_id) as cnt_prd_customerfrom temp_01group by 1,2order by 1,3)-------- 동시구매 고객 수, temp_06 as (select customer_id, count(order_id) as cnt_customerfrom ordersgroup by 1)------ 구매횟수, temp_07 as (select distinct t5.prd_01, t5.prd_02, cnt_prd_customer as 동시구매고객수, sum(cnt_customer) as 구매횟수, cnt_prd_prd as 동시구매횟수, cnt_prd_prd/sum(cnt_customer) as 동시구매율from temp_01 t1 join temp_05 t5 on t5.prd_01 = t1.prd_01 and t5.prd_02 = t1.prd_02join temp_06 t6 on t1.customer_id = t6.customer_idjoin temp_03 t3 on t1.prd_01 = t3.prd_01 and t1.prd_02 = t3.prd_02group by 1,2,3,5order by 1,5 desc) ---/ 동시구매 고객 수 / 구매 횟수 / 동시구매 횟수 / 동시구매율, temp_08 as (select distinct country, year_ord , month_ord , prd_01, cnt_prd as 구매고객수from temp_01 t1 join temp_04 t4 on t1.prd_01 = t4.product_idorder by 1,2,3,4)---국가/ 기준월 / 대표제품명 / 구매고객수select distinct t8.*, prd_02, 동시구매고객수, 구매횟수, 동시구매횟수, 동시구매율from temp_08 t8 join temp_07 t7 on t8.prd_01 = t7.prd_01;