FineBI实战项目一(8):每天每小时订单笔数

1 明确数据分析目标

统计每个小时产生的订单个数

2 创建用于保存数据分析结果的表

create table app_hour_orders(
  id int primary key auto_increment,
  daystr varchar(20),
  hourstr varchar(20),
  cnt int
);

3 编写SQL语句进行数据分析

select
	substring(createTime,1,10) as daystr,
	substring(createTime,12,2) as hourstr,
	count(*) as cnt
from ods_finebi_orders
group by
	substring(createTime,1,10),substring(createTime,12,2)
order by hourstr;

FineBI实战项目一(8):每天每小时订单笔数_第1张图片

4 加载数据到结果表中

insert into app_hour_orders
select
	null,
	substring(createTime,1,10) as daystr,
	substring(createTime,12,2) as hourstr,
	count(*) as cnt
from ods_finebi_orders
group by
	substring(createTime,1,10),substring(createTime,12,2)
order by hourstr;

FineBI实战项目一(8):每天每小时订单笔数_第2张图片

你可能感兴趣的:(FineBI,finebi,数据库,大数据)