FineBI实战项目一(7):每天每小时上架商品个数

1 明确数据分析目标

对所有商品的商家时间进行统计,统计每个小时上架商品的个数

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

create table app_hour_goods(
  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_goods
group by
	substring(createTime,1,10),substring(createTime,12,2)
order by hourstr;

4 加载数据到结果表中

insert into app_hour_goods
select
	null,
	substring(createTime,1,10) as daystr,
	substring(createTime,12,2) as hourstr,
	count(*) as cnt
from ods_finebi_goods
group by
	substring(createTime,1,10),substring(createTime,12,2)
order by hourstr;
相关推荐
qq_5298353539 分钟前
对计算机中缓存的理解和使用Redis作为缓存
数据库·redis·缓存
月光水岸New3 小时前
Ubuntu 中建的mysql数据库使用Navicat for MySQL连接不上
数据库·mysql·ubuntu
狄加山6753 小时前
数据库基础1
数据库
我爱松子鱼3 小时前
mysql之规则优化器RBO
数据库·mysql
chengooooooo4 小时前
苍穹外卖day8 地址上传 用户下单 订单支付
java·服务器·数据库
Rverdoser5 小时前
【SQL】多表查询案例
数据库·sql
Galeoto5 小时前
how to export a table in sqlite, and import into another
数据库·sqlite
人间打气筒(Ada)5 小时前
MySQL主从架构
服务器·数据库·mysql
leegong231115 小时前
学习PostgreSQL专家认证
数据库·学习·postgresql
喝醉酒的小白5 小时前
PostgreSQL:更新字段慢
数据库·postgresql