zoukankan      html  css  js  c++  java
  • 小记

    Data Source=10.0.8.14;User ID=sa;Password=123;Initial Catalog=dnt31;Pooling=true

    set @circleId = 1;
    set @startDate = '2014-08-01 00:00:00';
    set @endDate = '2014-12-30 23:59:59';
    insert into app_day_count_log(dau_count,circle_id,created_at,updated_at)
    select dau_count,circle_id,concat(created_at,' ',curtime())created_at,concat(updated_at,' ',curtime())updated_at from(
    select count(distinct a.fromUserName)dau_count,b.app_shop_circle_id circle_id,date_format(a.created_at,'%Y-%m-%d')created_at,date_format(a.created_at,'%Y-%m-%d')updated_at from app_wechat_request a,app_member_info b
    where a.fromUserName = b.openid and b.app_shop_circle_id = @circleId and a.created_at>= @startDate and a.created_at<= @endDate group by created_at)c


    ---使用
    select y.giftname,ifnull(z.count,0)count from(select b.name_cn giftname from app_coupon_log a,app_gift_info b where (b.gift_type=1 or b.gift_type=3) and b.price=0 and a.app_gift_info_id = b.id and b.is_delete=0 and a.created_at between '2014-12-01' and '2014-12-31 23:59:59' group by a.app_gift_info_id)y left join
    (select m.salename giftname,ifnull(n.usecount,0)count from(select count(a.app_gift_info_id)salecount,b.name_cn salename
    from app_gift_log a,app_gift_info b where (b.gift_type=1 or b.gift_type=3) and a.app_gift_info_id = b.id and b.is_delete=0 and a.status_type = 2 and a.use_time between '2014-12-01' and '2014-12-31 23:59:59' group by a.app_gift_info_id)m
    left join (select count(a.app_gift_info_id)usecount,b.name_cn usename from app_gift_log a,app_gift_info b where (b.gift_type=1 or b.gift_type=3) and a.app_gift_info_id = b.id and b.is_delete=0 and a.use_type = 1 and a.use_time between '2014-12-01' and '2014-12-31' group by a.app_gift_info_id)n on m.salename=n.usename)z on y.giftname=z.giftname group by giftname;

    ---销量
    select y.giftname,ifnull(z.count,0)count from(select b.name_cn giftname from app_coupon_log a,app_gift_info b where (b.gift_type=1 or b.gift_type=3) and b.price=0 and a.app_gift_info_id = b.id and b.is_delete=0 and a.created_at between '2014-12-01' and '2014-12-31 23:59:59' group by a.app_gift_info_id)y left join
    (select count(a.app_gift_info_id)count,b.name_cn giftname from app_gift_log a,app_gift_info b where (b.gift_type=1 or b.gift_type=3) and b.price=0 and a.app_gift_info_id = b.id and b.is_delete=0 and a.status_type in (1,2,4,5,6) and a.created_at between '2014-12-01' and '2014-12-31 23:59:59' group by a.app_gift_info_id)z on y.giftname=z.giftname group by giftname;

  • 相关阅读:
    Python学习笔记--8.3 函数--返回值
    Python学习笔记--8.2 函数--默认值参数
    Python学习笔记--9 非空即真,非零即真
    [Robot Framework] 支持python 3 的 robot framework 安装
    Mysql DB 无法创建 function,报错:ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL
    vue项目中console.log报错 No Console
    git命令合并分支代码
    远程桌面连接时如何使用本地扬声器和麦克风
    [Grafana] 如何把不同series的点用线连接起来
    POM 文件参考
  • 原文地址:https://www.cnblogs.com/fx2008/p/4212460.html
Copyright © 2011-2022 走看看