MySQL查询用户行为,网站用户行为分析

语句:select day(visit_date) from bigdata_user limit 10;

行为日期

20210102114148866346.png

购买行为的记录数、不同用户数

语句:select count(distinct uid) from bigdata_user where behavior_type=‘4’;

20210102114148897546.png

按日期统计记录数、用户数

语句:select count(distinct uid),day(visit_date) from bigdata_user where behavior_type=‘4‘ group by day(visit_date) limit 10;

20210102114149209550.png

语句:select count(*),day(visit_date) from bigdata_user where behavior_type=‘4‘ group by day(visit_date) limit 10;

20210102114149505954.png

保存为表格

语句:create table day_count as select count(*),day(visit_date) from bigdata_user where behavior_type=‘4‘ group by day(visit_date);

20210102114149817958.png

语句:create table day_uid as select count(distinct uid),day(visit_date) from bigdata_user where behavior_type=‘4‘ group by day(visit_date);

20210102114150098761.png

12号+购买行为

语句:select * from bigdata_user where behavior_type=‘4‘and visit_date=‘2014-12-12‘ limit 10;

20210102114150332764.png

按用户编号分组

语句:select uid from bigdata_user where behavior_type=‘4‘and visit_date=‘2014-12-12‘ group by uid limit 10;

20210102114150551167.png

按用户分组统计

语句:select uid,count(*) from bigdata_user where behavior_type=‘4‘and visit_date=‘2014-12-12‘ group by uid limit 10;

20210102114150831971.png

12号,购买,4项以上

语句:select uid,count(*) from bigdata_user where behavior_type=‘4‘and visit_date=‘2014-12-12‘ group by uid having count(*)>4 limit 10;

20210102114151050374.png

语句:select uid,count(*) from bigdata_user where behavior_type=‘4‘and visit_date=‘2014-12-12‘ group by uid having count(behavior_type=‘4‘)>4 limit 10;

20210102114151268776.png

2014-12-12号当天广东购买商品数

语句:select count(*)from bigdata_user where visit_date=‘2014-12-12‘ and province=‘广东‘;

20210102114151331177.png

按省份统计购买数量

语句:select count(*)from bigdata_user group by province;

20210102114151533980.png

20210102114151767983.png

2014-12-12号当天的商品购买与浏览比例

语句:select count(*)from bigdata_user where visit_date=‘2014-12-12‘ and behavior_type=‘4‘ limit 10;

20210102114151986386.png

用户10001082在2014-12-12号当天活跃度:该用户点击行为占该天所有点击行为的比例

语句:select count(*)from bigdata_user where visit_date=‘2014-12-12‘ and uid=‘10001082‘;

20210102114152189188.png

20210102114152220389.png

2014-12-12号当天购买4件商品以上的用户

语句:select uid,count(*)from bigdata_user where behavior_type=‘4‘ and visit_date=‘2014-12-12‘ group by uid having count(*)>4;

20210102114152501192.png

20210102114152750795.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值