Answer the question
In order to leave comments, you need to log in
How to fill the sample result with gaps?
There is a request:
SELECT `date`, SUM(`visits`) as `sum`, DATE_FORMAT(FROM_UNIXTIME(`date`), '%M %Y') as `period` FROM `statistics` WHERE `е_id` = 10 GROUP BY `period` ORDER BY `date` ASC
date sum period
1453323600 7 January 2016
1456693200 4 February 2016
1456779600 9 March 2016
1461099600 11 April 2016
1464728400 12 June 2016
1468443600 5 July 2016
date sum period
1453323600 7 January 2016
1456693200 4 February 2016
1456779600 9 March 2016
1461099600 11 April 2016
1464123600 0 May 2016 // Информация за май
1464728400 12 June 2016
1468443600 5 July 2016
Answer the question
In order to leave comments, you need to log in
first form an empty array in which all dates = zeros.
Then fill it with a selection from the database.
I think (and this solution is used in real projects) you need a table for the calendar, in business systems this is also done to mark working / non-working days.
by linking your table with the calendar table, you can normally get "skips"
one problem - the calendar must be supported.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question