MySQL - Contagem máxima de visitas por período de data e hora
Tenho uma tabela de visitas (id int, data e hora de início e data final) e você deseja acompanhar as contagens de pico de visitas.
Dados de exemplo:
+------+---------------------+---------------------+
| id | date-time-1 | date-time-2 |
+------+---------------------+---------------------+
| 1059 | 2016-07-04 19:13:00 | 2016-07-04 19:20:05 |
| 1060 | 2016-07-04 19:13:30 | 2016-07-04 19:14:25 |
| 1061 | 2016-07-04 19:14:39 | 2016-07-04 19:20:05 |
| 1062 | 2016-07-05 02:34:40 | 2016-07-05 02:45:23 |
| 1063 | 2016-07-05 02:34:49 | 2016-07-05 02:45:34 |
+------+---------------------+---------------------+
O resultado esperado deve ser:
+-------------------------------------------+-------+
| date-time-1 | date-time-2 | count |
+-------------------------------------------+-------+
| 2016-07-04 19:13:00 | 2016-07-04 19:13:29 | 1 |
| 2016-07-04 19:13:30 | 2016-07-04 19:14:25 | 2 |
| 2016-07-04 19:14:26 | 2016-07-04 19:14:38 | 1 |
| 2016-07-04 19:14:39 | 2016-07-04 19:20:05 | 2 |
| 2016-07-04 19:20:06 | 2016-07-05 02:34:39 | 0 |
| 2016-07-05 02:34:40 | 2016-07-05 02:34:48 | 1 |
| 2016-07-05 02:34:49 | 2016-07-05 02:45:23 | 2 |
| 2016-07-05 02:45:24 | 2016-07-05 02:45:34 | 1 |
+------+------------------------------------+-------+