2019-07-05

一.重点sql

1.hive动态分区

set hive.exec.dynamici.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;


insert overwrite table mds_new_user_temp   partition (dt)
select uid,first_date,last_date,app_platform,app_version,wm,dt
from mds_mbportal_newsclient_activate_retain_normaluser
where dt between 20190625 and 20190703
and pt_channel='news'
and pt_type='activate'
and wm not in ('12030_0001','12040_0001','12433_0001','12040_0006')
and concat(substr(first_date,1,4),substr(first_date,6,2),substr(first_date,9,2))=dt 
and first_date=last_date;

2.回访计算

create table  xiaojie_retain as
select a.dt,a.ustat
from 
(--获取统计期间内去互保新用户的dt,uid,first_date
select  dt,uid as ustat,first_date,
case
when app_platform in ('Android','Android_Lite','Android_Pad','Android_TV') then 'android'
when app_platform in ('iPad','iPhone') then 'ios'
else 'others' end as app_platform
from mds_mbportal_newsclient_activate_retain_normaluser --去互保用户表
where dt='20180919'
and pt_channel='news' 
and pt_type='activate'
and dt = concat(substr(last_date,1,4),substr(last_date,6,2),substr(last_date,9,2))
and first_date=last_date
)a 
inner join 
(-- 用于计算次日留存
select  dt,uid as ustat,
date_sub(concat_ws('-', substring(dt,1,4), substring(dt,5,2), substring(dt,7,2)),1) dt_1
from mds_mbportal_newsclient_activate_retain_normaluser --去互保用户表
where dt='20180920'
and pt_channel='news' 
and pt_type='activate'
and dt = concat(substr(last_date,1,4),substr(last_date,6,2),substr(last_date,9,2))
)e 
on a.ustat=e.ustat and  concat(substr(a.dt,1,4),'-',substr(a.dt,5,2),'-',substr(a.dt,7,2))=e.dt_1

3.linux常用

  • 统计词频:find -name "*zip" | wc -l
  • 修改权限:chgrp huzhuzhe t.txt
  • 大小写敏感:grep -i "huzhuzhe"

更多参考见:https://www.jianshu.com/p/c8259702a22e

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一.重点sql 1.hive动态分区 2.回访计算 3.linux常用 统计词频:find -name "*zip...
    胡竹哲阅读 71评论 0 0
  • 操作系统的管理命令 1 准备知识说明 1)命令提示符的概念:提示可以输入命令例如: [ root @ oldbo...
    寻找_f34c阅读 323评论 0 0
  • 1.安装系统包和部分软件包 yum -y install patch make gcc gcc-c++ gcc-g...
    彬荣阅读 346评论 0 0
  • 引言:在简书潜水一年多,最近才开始深入了解简书。谢谢简友的留言、点赞与支持。谈谈自己最近收获,愿对大家有所触动。 ...
    创造全新幸福生活阅读 313评论 3 6
  • 咳咳/文 《奇异博士》这部电影最近比较火,貌似豆瓣前期评分9.0,给很多人给安利了这个片子。昨晚去看了《奇异博士》...
    雨中蘑菇阅读 1,268评论 0 1

友情链接更多精彩内容