E
E
Evgeny Kuznetsov2016-04-25 02:24:15
MySQL
Evgeny Kuznetsov, 2016-04-25 02:24:15

How to fill in missing records in a MySQL selection grouped by day/hour?

There is a table, statistics on user transitions are written to it.
It has a timestamp field.
I make a selection by the number of records for a certain hour / day and group by this hour / day, but if there was no transition at a certain hour / day, then accordingly this record will not fall into the selection and will not be displayed on the chart.
How to fill in these missing entries so that everything is consistent?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Ivanov, 2016-04-25
@Writerim

The easiest way is to prepare a TEMPORARY table with a timestamp and substitute the values ​​with your table via LEFT JOIN.

N
nozzy, 2016-04-25
@nozzy

stackoverflow.com/questions/24305085/including-mis...
stackoverflow.com/questions/10429611/mysql-group-b...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question