博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
移动分发端 基础统计指标经典业务代码节选--二次激活用户
阅读量:6953 次
发布时间:2019-06-27

本文共 1888 字,大约阅读时间需要 6 分钟。

hot3.png

二次激活的俩种定义:(以下的实现主要是hiveQL实现)

第一种定义

--二次激活 在首次登陆日期后的30天内有登陆的用户from log_db.login_etlinsert overwrite table temp_u_statusers_sec partition(td=1)select firstlogindate statdate,${period} period,softid,platform,firstchannelid      ,count(distinct imei) NewUserCount_SecAct,1 flagwhere dt>='${datestart}' and dt<='${dateend}' and logindate!=firstlogindate and firstlogindate>=${firstlogindate} and firstlogindate<=${lastlogindate} and flag&1=0group by firstlogindate,softid,platform,firstchannelidinsert overwrite table temp_u_statusers_sec partition(td=2)select firstlogindate statdate,${period} period,softid,platform,0 channelid      ,count(distinct imei) NewUserCount_SecAct,1 flagwhere dt>='${datestart}' and dt<='${dateend}' and logindate!=firstlogindate and firstlogindate>=${firstlogindate} and firstlogindate<=${lastlogindate} and flag&1=0group by firstlogindate,softid,platform;
--第二种定义--过去30天内用户在统计日激活用户数--百度二次激活,1获取新增用户,2筛选出该端时间内没有登陆的用户 3,没有登陆用户在统计时间登陆用户insert overwrite table temp_u_statusers_sec2select  c.softid,c.platform,c.channelid,count(1) newusercount_sec2 from (      select softid,platform,firstchannelid channelid,imei,count(distinct logindate) s      from log_db.login_etl      where  dt>='${datestart}' and dt<='${dateend2}' and firstlogindate>=${firstlogindate}      and firstlogindate<=${lastlogindate}      group by softid,platform,firstchannelid,imei        having count(distinct logindate)=1  ) c inner join  (    select softid,platform,firstchannelid channelid,imei    from log_db.login_etl    where  dt='${dir}' and logindate!=firstlogindate and firstlogindate>=${firstlogindate}      and firstlogindate<=${lastlogindate}    group by softid,platform,firstchannelid,imei  )  don c.softid=d.softid and c.platform=d.platform and c.imei=d.imeigroup by c.softid,c.platform,c.channelid;

个人感觉第二种的写法有偷巧的意思,想比于所写的思路来看,效率更好也更高

转载于:https://my.oschina.net/osenlin/blog/523424

你可能感兴趣的文章
探究underscore源码(一)
查看>>
Java IO详解
查看>>
使用 ES2015 开发 Angular1.x 应用指南
查看>>
密码学协议 门限
查看>>
true or false in JavaScript
查看>>
Android学习笔记6:使用Intent1
查看>>
js实现继承的几种方式
查看>>
[LintCode/LeetCode] Two Strings are Anagrams/Valid Anagram
查看>>
Consul入门03 - 注册服务
查看>>
[Centos]necessary tools for newbie
查看>>
前端临床手札——单元测试
查看>>
Java IO : File
查看>>
JavaScript Ajax与Comet——“进度事件”的注意要点
查看>>
[单刷APUE系列]第四章——文件和目录[2]
查看>>
MySQL Replication
查看>>
JavaScript数组去重总结
查看>>
MVVM_Android-CleanArchitecture
查看>>
iOS开发-协议Protocol&代理delegate
查看>>
【系统架构师修炼之道】(4):绪论——Zachman 框架
查看>>
Foxify v0.10.7 发布,基于 TypeScript 的 Node 框架
查看>>