Я рассчитываю подсчитать количество записей на основе совпадения значений даты и времени:
create table `weather` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
`dt_iso` datetime DEFAULT NULL,
`weather_main` varchar(60) DEFAULT NULL);
insert into `weather` (`dt_iso`,`weather_main`) values ("2019-01-01 23:00:00","cloud"), ("2019-01-02 00:00:00","sun"), ("2019-01-02 01:00:00","cloud");
create table `incidents` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
`Incident_Date` datetime DEFAULT NULL);
insert into `incidents` (`Incident_Date`) values ("2019-01-01 23:50:00"), ("2019-01-01 23:50:00"), ("2019-01-09 10:05:00");
В SQL Fiddle: http://sqlfiddle.com/#! 9 / 489f57
Это тип вывода, который я ищу:
dt_iso, weather_main, count(incidents),
2019-01-01T23:00:00, cloud, 0
2019-01-02T00:00:00, sun, 2
2019-01-02T01:00:00, cloud, 0