按渠道计算 PV 和 UV

按渠道计算 PV 和 UV:

------------------按指定channel_id按月求PV、UV------------
drop table if exists tmp_pvuv;
create table tmp_pvuv
as
select
    t1.channel_id,                              --渠道编号
    t2.year_month,                              --年份月份
    count(distinct t2.visitor_trace) as UV,     --UV     
    sum(t2.pv) as PV                            --PV
from tmp_wangbo3_092502_channelid t1
join
    (select
        from_unixtime(unix_timestamp(dt,'yyyyMMdd'),'yyyy-MM') as year_month,
        pvalue,
        visitor_trace,
        pv
    from dw.kn2_traf_web_log_total  --流量表
    where dt>='20160101' and dt<='20170630'  --2016年1月1日至2017年6月30日
    ) t2 on t1.channel_id=t2.pvalue
group by t1.channel_id,t2.year_month  --按channel_id分组
;

 

转载于:https://www.cnblogs.com/shujuxiong/p/9289727.html

    原文作者:weixin_30835933
    原文地址: https://blog.csdn.net/weixin_30835933/article/details/98408249
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞