1. データ分析の目的を明確にする
すべての注文で各カテゴリに対応する製品の数を数え、ワード クラウド図を作成します。
2 データ分析結果を保存するテーブルを作成する
create table app_cat_cnt(
id int primary key auto_increment,
daystr varchar(20),
catName varchar(100),
cnt int
);
3. データ分析用の SQL ステートメントを作成する
select
substring(a.createTime,1,10) as daystr,
c.catName,
count(*) as cnt
from ods_finebi_order_goods a
join ods_finebi_goods b on a.goodsId = b.goodsId
join ods_finebi_good_cats c on b.goodsCatId = c.catId
group by c.catName, substring(a.createTime,1,10)
order by cnt desc;
4 結果テーブルにロードする
insert into app_cat_cnt
select
null,
substring(a.createTime,1,10) as daystr,
c.catName,
count(*) as cnt
from ods_finebi_order_goods a
join ods_finebi_goods b on a.goodsId = b.goodsId
join ods_finebi_good_cats c on b.goodsCatId = c.catId
group by c.catName, substring(a.createTime,1,10)
order by cnt desc;