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;

  • 相关阅读:
    Java根据html模板创建 html文件
    java.lang.NumberFormatException: For input string:"filesId"
    使用java开源工具httpClient及jsoup抓取解析网页数据
    JBPM5流程设计器jbpm-designer-2.4.0.Final-tomcat.war的部署没法访问的问题
    MyEclipse8.0 注册码生成代码
    图片转为byte[]、String、图片之间的转换
    java中Xml、json之间的相互转换
    java二维码小试牛刀
    进度条脚本
    如何制作一寸、二寸、六寸照片。以后不用再去照相馆了!!! 转~版本更新
  • 原文地址:https://www.cnblogs.com/fx2008/p/4212460.html
Copyright © 2011-2022 走看看