I currently have two tables in mysql that are collecting data. One collects every 3 hours and the other every 15 minutes. I am trying to create a forecast using this data using machine learning techniques which requires the data to be of the same time interval.
My question is, how can I get the average value for every 3 hours from both tables into a new table that organises them by date and hour? So of a format like:
Date / Hour / Table 1 3-hour average / Table 2 3-hour average
Table 1 (every 3 hours): datetime(timestamp)/level(double)
Table 2 (every 15 minutes): datetime(timestamp)/value(double)
I have managed to create a table that gives me the average per day, but I'd prefer something more accurate!
This is the statement I've already got for daily averages:
SELECT DAY(`datetime`),
AVG(`level`) AS `Table 1 Average` ,
(SELECT AVG(`value`) AS `Table 2 Daily Average`
FROM `table2`
WHERE DAY(`datetime`) = DAY(table1.datetime)
GROUP BY DAY(`datetime`))
FROM `table1` GROUP BY DAY(`datetime`);
Thanks!