渠道映射等關系


 

 

1 第一步先新建一個渠道hmsr

 

 

2 新建渠道資源映射管理

 

 

 

3 在需要輸出的報表里,添加新增的hmsr 渠道名稱

 

 

 

4 附上需要明細SQL

--odps sql 
--********************************************************************--
--description:保姆DSP朋友圈渠道數據報表
--author:shanwei
--create time:2018-12-19 11:12:00
--modifier:單偉
--modify reason:改為全量更新數據(2019-01-01以后),刪掉分區
--modify time:2019-06-20 15:20:00
--********************************************************************--
insert overwrite table a_bm_dsp_channel_statistical

select
     dates
     ,hmsr
     ,name_2
     ,sum(pv_num) pv_num --PV(訪問量)
     ,sum(uv_num) uv_num  --UV(用戶量)
     ,sum(clue_num) clue_num  --線索數
     ,sum(eff_clue_num) eff_clue_num  --有效線索數
     ,sum(sign_num) sign_num --簽單數
      ,sum(audit_order) as audit_order
    ,sum(a_audit_order) as a_audit_order
    ,sum(b_audit_order) as b_audit_order
from (
     --計算 PV、UV
     select
          to_date(a.dt,'yyyymmdd') dates
          ,a.hmsr
          ,b.name_2
          ,count(a.cookie_id) pv_num  --PV(訪問量)
          ,count(distinct a.cookie_id) uv_num  --UV(用戶量)
          ,0 clue_num   --線索數
          ,0 eff_clue_num  --有效線索數
          ,0 sign_num    --簽單數
           ,0 as audit_order
        ,0 as a_audit_order
        ,0 as b_audit_order
     from (
         select *
         from f_jz_traffic_base
         where cate_id like '2%'    --取保姆
           and dt >= '20190101'
           and event_type='pageview'
           ) a
     left join d_source b
            on a.source_id = b.id
     where b.name_2 in ('DSP_微信朋友圈','DSP_快手','DSP_知乎','DSP_閃投','DSP_網易新聞','DSP_搜狐新聞', 'DSP_一點資訊','DSP_粉絲通','DSP_UC頭條')
     group by a.dt,a.hmsr,b.name_2

     union all
     --計算線索
     select
          to_date(substr(a.create_time,1,10),'yyyy-mm-dd') dates
          ,a.max_hmsr as hmsr
          ,b.name_2
          ,0 pv_num  --PV(訪問量)
          ,0 uv_num  --UV(用戶量)
          ,count(distinct a.id) as clue_num --線索數
          ,0 eff_clue_num --有效線索數
          ,0 sign_num --簽單數
           ,0 as audit_order
        ,0 as a_audit_order
        ,0 as b_audit_order
     from (
         select *
         from f_jz_clue_main
         where category_id = 212
            and substr(create_time,1,10) >= '2019-01-01'
          ) a
     left join d_source b
            on a.original_source_id = b.id
     where b.name_2 in ('DSP_微信朋友圈','DSP_快手','DSP_知乎','DSP_閃投','DSP_網易新聞','DSP_搜狐新聞', 'DSP_一點資訊','DSP_粉絲通','DSP_UC頭條')
     group by substr(a.create_time,1,10),a.max_hmsr,b.name_2
     
     union all
     --計算有效線索
     select
          to_date(substr(a.chance_create_time,1,10),'yyyy-mm-dd') dates
          ,a.max_hmsr as hmsr
          ,b.name_2
          ,0 pv_num  --PV(訪問量)
          ,0 uv_num  --UV(用戶量)
          ,0 clue_num --線索數
          ,count(distinct a.id) eff_clue_num --有效線索數
          ,0 sign_num --簽單數
           ,0 as audit_order
        ,0 as a_audit_order
        ,0 as b_audit_order
     from (
         select *
         from f_jz_clue_main
         where category_id = 212
            and substr(chance_create_time,1,10) >= '2019-01-01'
          ) a
     left join d_source b
            on a.original_source_id = b.id
     where b.name_2 in ('DSP_微信朋友圈','DSP_快手','DSP_知乎','DSP_閃投','DSP_網易新聞','DSP_搜狐新聞', 'DSP_一點資訊','DSP_粉絲通','DSP_UC頭條')
     group by substr(a.chance_create_time,1,10),a.max_hmsr,b.name_2
     
     union all
     --計算簽單量
     select
          to_date(substr(a.order_date,1,10),'yyyy-mm-dd') dates
          ,clue.max_hmsr as hmsr
          ,b.name_2
          ,0 pv_num  --PV(訪問量)
          ,0 uv_num  --UV(用戶量)
          ,0 clue_num --線索數
          ,0 eff_clue_num --有效線索數
          ,count(distinct a.id) sign_num --簽單數
           ,0 as audit_order
        ,0 as a_audit_order
        ,0 as b_audit_order
     from (
         select *
         from f_jz_order_main
         where category_id = 212
            and substr(order_date,1,10) >= '2019-01-01'
          ) a
     left join f_jz_clue_main clue
            on a.clue_id = clue.id
     left join d_source b
            on a.original_source_id = b.id
     where b.name_2 in ('DSP_微信朋友圈','DSP_快手','DSP_知乎','DSP_閃投','DSP_網易新聞','DSP_搜狐新聞', 'DSP_一點資訊','DSP_粉絲通','DSP_UC頭條')
     group by substr(a.order_date,1,10),clue.max_hmsr,b.name_2

      union all
     --計算審核單量
     select
          to_date(substr(work_date,1,10),'yyyy-mm-dd') dates
          ,null as hmsr
          ,last_name_2 name_2
          ,0 pv_num  --PV(訪問量)
          ,0 uv_num  --UV(用戶量)
          ,0 clue_num --線索數
          ,0 eff_clue_num --有效線索數
          ,0 as sign_num
          ,sum(aduit) as audit_order
          ,sum(label_type_a_ne_aduit) as a_audit_order
          ,sum(label_type_b_ne_aduit) as b_audit_order
     from 
         m_bm_adviser_quota_all
     where 
        dt = '${bdp.system.bizdate}'
     group by 
         work_date 
          ,last_name_2
      ) t
group by dates,hmsr,name_2

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM