我试图计算每天每小时发布的平均帖子,我必须这样做 113 个月。Post 表内部有这个属性 timePosted、DatePosted 和 Text。我还需要加入两个表格帖子和线程,因为我只想获得类别 ID 编号 3。
到目前为止,这是我已经完成的查询。
select datePost as daytime,
HOUR(timePost) as thehour,
count(TEXT) as thecount
from post, thread
where date(post.datePost) BETWEEN '2010-05-01' AND '2010-05-31'
and post.threadID = thread.threadID
and thread.CatID = 3
group by datePost, thehour
上面的子查询返回给我这个:
daytime thehour thecount
'2010-05-01', '0', '3'
'2010-05-01', '1', '16'
'2010-05-01', '2', '2'
'2010-05-01', '4', '1'
'2010-05-01', '7', '1'
我尝试进行平均,但问题是它返回的数字与计数相同。示例 thecount 为 3,然后 Avg 返回我 3.00000
所以我试图得到这个结果:
daytime thehour thecount Avg
'2010-05-01', '0', '3' #
'2010-05-01', '1', '16' #
'2010-05-01', '2', '2' #
'2010-05-01', '4', '1' #
'2010-05-01', '7', '1' #