FineBI practical project one (5): Analysis of the total number of users who place orders every day

1. Clarify the goals of data analysis

Count the total number of users placing orders every day

2 Create a table to save data analysis results

use finebi_shop_bi;

create table app_order_user(
    id int primary key auto_increment,
    dt date,
    total_user_cnt int
);

3. Write SQL statements for data analysis

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);

4 Load data into the results table

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);

Guess you like

Origin blog.csdn.net/u013938578/article/details/135453029