APP資料模擬處理流程—[視窗分析函式]
阿新 • • 發佈:2019-01-25
2018-05-19,唐尼,鋼鐵俠,360應用,紐約,v2.0 2018-05-19,唐尼,鋼鐵俠,360應用,紐約,v1.2 2018-05-19,唐尼,鋼鐵俠,360應用,紐約,v2.0 2018-05-19,唐尼,鋼鐵俠,360應用,紐約,v1.2 2018-05-19,唐尼,鋼鐵俠,安卓市場,紐約,v1.6 2018-05-19,唐尼,鋼鐵俠,360應用,紐約,v1.3 2018-05-19,唐尼,鋼鐵俠,360應用,紐約,v2.0 2018-05-19,託尼,鋼鐵俠,360應用,紐約,v2.0 2018-05-19,託尼,鋼鐵俠,360應用,紐約,v1.2 2018-05-19,託尼,鋼鐵俠,安卓市場,紐約,v1.6 2018-05-19,唐尼,鋼鐵俠,360應用,紐約,v1.3 2018-05-19,託尼,鋼鐵俠,360應用,紐約,v2.0 create table t_lag_test(day string,user_id string,app_token string,release_channel string,city string,app_ver_name string) row format delimited fields terminated by ','; load data local inpath '/root/hivetest/ver.test' into table t_lag_test; select day,user_id,app_token,release_channel,city,ver_pre,app_ver_name from (select day,user_id,app_token,release_channel,city,app_ver_name, lag(app_ver_name,1,null) over(partition by user_id order by app_ver_name) as ver_pre from t_lag_test)tmp where ver_pre is not null and tmp.app_ver_name>ver_pre;