每日优惠券行为
简单的累加
类似的有:每日活动行为,每日购买行为
insert overwrite table dws_coupon_use_daycount partition(dt='2020-03-10') select cu.coupon_id, ci.coupon_name, ci.coupon_type, ci.condition_amount, ci.condition_num, ci.activity_id, ci.benefit_amount, ci.benefit_discount, ci.create_time, ci.range_type, ci.spu_id, ci.tm_id, ci.category3_id, ci.limit_num, cu.get_count, cu.using_count, cu.used_count from ( select coupon_id, sum(if(date_format(get_time,'yyyy-MM-dd')='2020-03-10',1,0)) get_count, sum(if(date_format(using_time,'yyyy-MM-dd')='2020-03-10',1,0)) using_count, sum(if(date_format(used_time,'yyyy-MM-dd')='2020-03-10',1,0)) used_count from dwd_fact_coupon_use where dt='2020-03-10' group by coupon_id)cu left join ( select * from dwd_dim_coupon_info where dt='2020-03-10' )ci on cu.coupon_id=ci.id;