且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MYSQL:在日期范围内聚合订单,其值为空值

更新时间:2021-11-26 05:28:14

您正在尝试引入数据中没有的结果行。这是不可能的(不使用存储过程 )。您不能在日期中迭代,所以说,SQL中没有循环的

You are trying to introduce result rows where there are none in the data. This is just not possible (without using a Stored Procedure). You cannot iterate over the dates as, so to say, there are no for loops in SQL.

最接近您可以得到/创建一个(临时)表,其结果中包含您希望拥有的所有日期,然后加入此表。

The closest you can get is having/creating a (temporary) table of all the dates you want to have in the result and then JOIN to this table.