SQL group by date, but get dates w/o records too

后端 未结 6 1379
臣服心动
臣服心动 2021-01-07 06:06

Is there an easy way to do a GROUP BY DATE(timestamp) that includes all days in a period of time, regardless of whether there are any records associated with th

6条回答
  •  感情败类
    2021-01-07 06:48

    Instead of using GROUP BY, make a table (perhaps a temporary table) which contains the specific dates you want, for example:

    24 Dec
    23 Dec
    22 Dec
    21 Dec
    20 Dec
    

    Then, join that table to the Orders table.

提交回复
热议问题