zoukankan      html  css  js  c++  java
  • mysql日期补全

    前提:订单表,有的日期没有订单,但是也要查询出来,并分页

    查询order表中2017-10-01  ----2017-10-31 已10 分页 查询出每天的订单数,没有的补0

    SELECT
        od.date,
        od.orderCount
    FROM
        (
            SELECT
                count(*) orderCount,
                DATE_FORMAT(order_time, '%Y-%m-%d') date
            FROM
                order_info
            WHERE
                order_time > '2017-10-1'
            AND order_time < '2017-10-31'
            GROUP BY
                DATE_FORMAT(order_time, '%Y-%m-%d')
            UNION    (SELECT 0, '2017-10-01')
            UNION    (SELECT 0, '2017-10-02')
            UNION    (SELECT 0, '2017-10-03')
            UNION    (SELECT 0, '2017-10-04')
            UNION    (SELECT 0, '2017-10-05')
            UNION    (SELECT 0, '2017-10-06')
            UNION    (SELECT 0, '2017-10-07')
            UNION    (SELECT 0, '2017-10-08')
            UNION    (SELECT 0, '2017-10-09')
            UNION    (SELECT 0, '2017-10-10')
            UNION    (SELECT 0, '2017-10-11')
            UNION    (SELECT 0, '2017-10-12')
            UNION    (SELECT 0, '2017-10-13')
            UNION    (SELECT 0, '2017-10-14')
            UNION    (SELECT 0, '2017-10-15')
            UNION    (SELECT 0, '2017-10-16')
            UNION    (SELECT 0, '2017-10-17')
            UNION    (SELECT 0, '2017-10-18')
            UNION    (SELECT 0, '2017-10-19')
            UNION    (SELECT 0, '2017-10-20')
            UNION    (SELECT 0, '2017-10-21')
            UNION    (SELECT 0, '2017-10-22')
            UNION    (SELECT 0, '2017-10-23')
            UNION    (SELECT 0, '2017-10-24')
            UNION    (SELECT 0, '2017-10-25')
            UNION    (SELECT 0, '2017-10-26')
            UNION    (SELECT 0, '2017-10-27')
            UNION    (SELECT 0, '2017-10-28')
            UNION    (SELECT 0, '2017-10-29')
            UNION    (SELECT 0, '2017-10-30')
            UNION    (SELECT 0, '2017-10-31')
        ) AS od
    LIMIT 10,10
  • 相关阅读:
    Configuring the launch of the remote virtual machine to debug
    java LimitedThreadPool
    java并发之SynchronousQueue实现原理
    java 线程池线程忙碌且阻塞队列也满了时给一个拒接的详细报告
    Java程序监控指标
    JDK提供的四种线程池
    Guava的Supplier实现单例
    JMM
    Dubbo源码解读:appendAnnotation [01]
    PCI(Payment Card Industry)合规
  • 原文地址:https://www.cnblogs.com/go4mi/p/7612299.html
Copyright © 2011-2022 走看看