二、网站用户行为分析
1.1 本地数据集上传到数据仓库Hive
1.2 Hive数据分析
1.3 Hive、MySQL、HBase数据互导
2.1 数据准备
移动文件到dataset文件夹下
语句:sed -i ‘1d‘ raw_user
语句:vim pre_deal.sh
语句:head - 10 user_table.txt
2.2 Hive数据分析
(1)用户行为分析需求:2014-12-11~12号有多少条购买商品的记录
分析步骤
(2)用户行为分析需求:分析每月1-31号购买情况
语句:select count(distinct uid),month(visit_date) from bigdata_user where buhavior_type = ‘4‘ group by month(visit_date);
截图:
(3)自定义需求:
1、2014-12-12号当天广东购买商品数
语句:select * from bigdata_user where behavior_type = ‘4‘ and visit_date = ‘2014-12-12‘;
截图:
2、按照省份统计购买数量
语句:select count(*) from bigdata_user where buhavior_type=‘4‘ group by province;
截图:
3、2014-12-12号当天的商品购买与浏览比例
语句:
select count(*) from bigdata_user where visit_date=‘2014-12-12‘and behavior_type=‘4‘;
截图:

语句:
select count(*) from bigdata_user where visit_date =‘2014-12-12‘;
截图:
4、用户10001082在2014-12-12号当天活跃度;该用户点击行为占该当天所有点击行为的比例
语句:select count(*) from bigdata_user where uid=10001082 and visit_date=‘2014-12-12‘;
截图:
语句:select count(*) from bigdata_user where visit_date=‘2014-12-12‘;
截图
5、2014-12-12号当天购买4件商品以上的用户
语句:select uid from bigdata_user where behavior_type=‘4‘ and visit_date=‘2014-12-12‘ group by uid having count(behavior_type=‘4‘)>4;
截图:
原文:https://www.cnblogs.com/kayss/p/14188145.html