SQL个人笔记——社区内容发帖数据统计逻辑总结

--内容社区发帖数据统计逻辑

--1-10月发帖量和发帖人数统计
select
     trunc(a.day,'MM') as month
    ,count(distinct a.tid) as tid_num  --可作为发帖数和发帖人数pv,这两个值等价
    ,count(distinct a.openid) as uv 
    ,count(a.openid) as pv   --改值有误,并不是实际的发帖人数pv,存在并集过多的情况
from
    (
    --发帖新口径
    select
         from_unixtime(publish, 'yyyy-MM-dd') as day
        ,open_id as openid   --作者id
        ,tid --帖子ID
    from
         eden.ods_vivocommunity_t_thread_info_df  --新的发帖表
    where 
         from_unixtime(publish, 'yyyy-MM-dd')  between '2020-01-01' and '2020-10-31'  
         and 
         tid is not null  --tid不为null
         --and tid <> ''  --tid不为空
    group by
         from_unixtime(publish, 'yyyy-MM-dd')
        ,open_id
        ,tid
    union all
    select
         s1.day as day 
        ,s2.openid as openid
        ,s1.tid as tid 
    from    
        (
        --发帖老口径
        select
             f
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值