Statistics order table daily, monthly and annual data

the time field in the order table is create_date,. Now count the number of orders per day or month.

the current statistics are as follows:
select DATE_FORMAT (create_date,"%Y% m% d") time,count (*) from order group by time

)

that"s what it looks like:

.
June 01, 2018 87
June 4, 2018 3
June 05, 2018

there may not be a single order for a few days, so you can"t find out the date and quantity of that day.
as I simulated above, No. 2 and No. 3 do not exist.
is hoping to find out

even if there is no order.

06.022018
03June2018

Mar.18,2021
If you don't have it in the

database, you can't find it, unless you save it once a day, and the default is 0.


it's really hard for you to say that, but it's not impossible. Your husband becomes a virtual table of the corresponding date, and then query the where condition according to the date in the virtual table. Well, it's that simple. You should write a stored procedure, because looping is not allowed outside the stored procedure. Of course, you are not recommended to do this, because it is easy to query the whole table. It is recommended that the corresponding data be counted and then handed over to the program for traversal. If there is a vacancy, the default setting shows that the day is empty.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b4022d-2bc68.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b4022d-2bc68.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?