MySQL: Calculate average post for every hour in each day.
I trying to calculate the average post made for every hour for each day
and I have to do this for 113 months. Inside the Post table have this
attribute timePosted, DatePosted and Text. I also need to join two table
post and thread because I only want to get category id number 3.
For each month I need to get this outcome:
Month: 1
Day Hour slot Avg of post created in each hours lot
Monday 00 ###
01 ###
.
.
23 ###
Tuesday Same as above
Month 2:
Day Hour slot Avg of post created in each hours lot
Monday 00 ###
01 ###
.
.
23 ###
Tuesday Same as above
and so on to month 113.
So far this query I have done.
select the_hour,avg(the_count)
from
(
select datePost as the_day,
HOUR(timePost) as the_hour,
count(TEXT) as the_count
from post, thread
where post.datePost = '2010-05-03'
and post.threadID = thread.threadID
and thread.CatID = 3
group by the_day,the_hour
) s
group by the_hour
The above query only do for each day. How should I get around to do for
every hour for each day and I have to do this for every month.
No comments:
Post a Comment