1 明确数据分析目标
统计每天下订单的总用户个数
2 创建用于保存数据分析结果的表
use finebi_shop_bi;create table app_order_user(id int primary key auto_increment,dt date,total_user_cnt int);
3 编写SQL语句进行数据分析
selectsubstring(createTime,1,10) as dt,count(distinct userId) as total_user_cntfromods_finebi_orderswheresubstring(createTime,1,10) = '2019-09-05'group bysubstring(createTime,1,10);
4 加载数据到结果表中
insert into app_order_userselectnull,substring(createTime,1,10) as dt,-- 2019-09-05这一天的日期count(distinct userId) as total_user_cntfromods_finebi_orderswheresubstring(createTime,1,10) = '2019-09-05'group bysubstring(createTime,1,10);