• 日常sql


    -- 京东卡领取数,按人统计
    select substr(create_time,1,7),count(distinct user_id) from t_esb_award_record where award_type_id = 2 and create_time > '2019-01-01 00:00:00' group by substr(create_time,1,7);

    -- 达标保单统计
    select substr(create_time,1,7),count(1) from t_plus_achive_target_record where create_time > '2019-01-01 00:00:00' group by substr(create_time,1,7);

    -- 京东卡领取数
    select substr(create_time,1,7),count(1) from t_esb_award_record where award_type_id = 2 and create_time > '2019-01-01 00:00:00' group by substr(create_time,1,7);

    -- 折扣券领取数
    select substr(create_time,1,7),count(1) from t_esb_award_record where award_type_id = 1 and create_time > '2019-01-01 00:00:00' group by substr(create_time,1,7);

     select count(distinct(policy_no))from t_order where create_time<'2020-04-01 00:00:00' and end_date> '1582992000000' and insurance_code in('P156') and del_flag = 0;

    select count(1),update_time from t_plus_achive_target_record where syn_flag = 2 and update_time like concat(substr(now(),1,10),'%') group by update_time;/*每天推送数据*/
    select count(1),update_time from t_plus_achive_target_record where syn_flag = 2 and update_time like concat(substr(date_sub(now(),interval 1 day) ,1,10),'%') group by update_time;/*上一天推送数据*/


    /*各个产品按小时统计*/
    select insurance_code,insurance_name,substr(create_time,1,13),count(1) from t_order where id > 1000000 and order_status> 5 and order_type = 1 and create_time > '2019-11-25 00-00-00' group by insurance_code,insurance_name,substr(create_time,1,13);
    /*各个产品统计*/
    select insurance_code,insurance_name,count(1) from t_order where id > 1000000 and order_status> 5 and order_type = 1 and create_time > '2019-11-25 00-00-00' and create_time < '2019-11-25 09-00-00' group by insurance_code,insurance_name;

  • 相关阅读:
    26.列表的循环遍历
    效率比较--链表
    心之距离 再回首 光年之遥远
    效率比较--集合
    效率比较--数组
    哈希表
    栈 VS 队列
    struts1 标签引入
    web 连接池配置
    zip&ftp命令
  • 原文地址:https://www.cnblogs.com/xingminghui/p/12607480.html
Copyright © 2020-2023  润新知