I need to either have a masive select statement or multiple queries. I need to break down data into specific timeframes during the day. This one works great for the first interval, but after that I’m stumped. If I have multiple queries, I’m having trouble with my “mysql_fetch_array”, as to the syntax (using something like ‘else’ and going through them).
SELECT U.user_name,ROUND(SUM((TA.task_average*TC.completed)/60),2) AS equiv1, S.submit_date,
SUM(TC.completed) AS ttasks1,
FROM `summary` S
JOIN users U ON U.user_id = S.user_id
JOIN tasks TA ON TA.task_id = S.task_id
JOIN tcompleted TC ON TC.tcompleted_id = S.tcompleted_id
JOIN minutes M ON M.minutes_id = S.minutes_id
WHERE DATE(submit_date) = curdate( )
AND TIME(submit_date) BETWEEN '06:00:00' and '07:59:59'
GROUP BY U.user_name
LIMIT 0 , 30
My fetch array ( I would need to have a bunch more, but how to I combine them?)
<?php
while($rows=mysql_fetch_array($result1)){
?>
ok, given that you want the data across regular 2 hourly intervals, you could try something like this:
where
FLOOR(hour(S.submit_date)/2)*2will map each hour to the first (even) hour of every 2 and you can group by this value. ie.update with php included:
some notes:
hoursderived table to ensure there are no‘gaps’ in the time intervals (assumed 6:00 – 20:00)
user, so we as we loop through the results we can print table cells for a given user and then print a new table row when the user changes.here’s the code: