tags:

views:

46

answers:

0

I'm using a helper table with all possible dates & hours for 2,5 years forward (26k rows) to fill out gaps for a given period set in my query.

Now I want to extend the precision of the analytics, by returning a resultset with rows by the MINUTE.

I'm a bit unsure how to accomplish this, since the helper table only have all possible dates and hours, not minutes.

Here is the query that gives me the results grouped in HOURS. Now I need some help on getting the results even more detailed, by grouping the rows in minutes.

SELECT calendar.date AS date, sum(lt.bytes) AS data
FROM logging.traffic AS lt 
RIGHT JOIN calendar ON (EXTRACT(DAY_HOUR FROM lt.date) = EXTRACT(DAY_HOUR FROM
calendar.date) AND lt.parentID = 2)
WHERE calendar.date BETWEEN CURDATE() - INTERVAL 1000 HOUR AND CURDATE()
GROUP BY calendar.date