不死鸟.亚历山大.狼崽子

不死鸟.亚历山大.狼崽子

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语句进行数据分析

select
	substring(createTime,1,10) as dt,
	count(distinct userId) as total_user_cnt
from
	ods_finebi_orders
where
	substring(createTime,1,10) = '2019-09-05'
group by
	substring(createTime,1,10);

FineBI实战项目一(5):每日下订单用户总数分析-LMLPHP

4 加载数据到结果表中

insert into app_order_user
select
  null,
  substring(createTime,1,10) as dt,-- 2019-09-05这一天的日期
  count(distinct userId) as total_user_cnt
from
  ods_finebi_orders
where
  substring(createTime,1,10) = '2019-09-05'
group by
  substring(createTime,1,10);

FineBI实战项目一(5):每日下订单用户总数分析-LMLPHP

01-10 23:57