zoukankan      html  css  js  c++  java
  • dws_coupon_use_daycount

    每日优惠券行为

    简单的累加

    类似的有:每日活动行为,每日购买行为

    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;
  • 相关阅读:
    事务
    MySQL删除表的方式
    建立索引的原则
    对表设置引擎
    运算符
    数据库锁简介
    为什么对表设置主键
    php苹果原生apns推送接口
    华为推送
    php操作redis
  • 原文地址:https://www.cnblogs.com/ldy233/p/14448739.html
Copyright © 2011-2022 走看看