将数据导入MySQL数据库
使用MySQL处理数据
# 计算不同时期的用户行为
create table ads_daily_behavior as
select substr(time,1,10) as busi_date,
count(case when behavior_type = 1 then behavior_type else null end) as pv,
count(distinct case when behavior_type = 1 then user_id else null end) as uv,
SUM(case when behavior_type = 3 then 1 else 0 end) as shopping_cart,
SUM(case when behavior_type = 2 then 1 else 0 end) as collect,
SUM(case when behavior_type = 4 then 1 else 0 end) as buy
FROM