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

后端 未结 6 1385
臣服心动
臣服心动 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:42

    One method is to create a calendar table and join against it.

    I would create it permanently, and then create a task that will insert new dates, it could be done weekly, daily, monthly, etc.

    Note, that I am assuming that you are converting your timestamp into a date.

提交回复
热议问题