1.分位数函数percentile
percentile(dau_days,0.5) as dau_days_50,
percentile(dau_days,0.6) as dau_days_60,
percentile(dau_days,0.8) as dau_days_80,
2.窗口函数(带滚动窗口)
#滚动30d dauavg(dau) over(order bydtm rows between 29 PRECEDINGand CURRENT ROW) as dau
在两个点之间滑动计算,用以下语句指定起点和终点:
sum(__) over(partition by __ order by __ROWS BWTWEEN <start> AND <finish> )<strat>和<finish>关键字如下:
2 PRECEDING #指定前2行
2 FOLLOWING #指定后2行
UNBOUNDED PRECEDING #前面所有行
YNBOUNDED FOLLOWING #后面所有行
CURRENT ROW #当前行
SQL窗口函数及Pandas实现
3.Hive常用日期格式转换
Hive常用日期格式转换