我有以下两个表:
帖子
- post_id
- 帖子标题
- post_timestamp
评论
- comment_id
- post_post_id
- 评论内容
- 评论时间戳
我想创建一个显示每周发帖数和评论数的报告。像这样的东西:
Week StartDate Posts Comments
1 1/1/2012 100 305
2 1/8/2012 115 412
我有这个查询,但它只从 Posts 表中提取。
select makedate( left(yearweek(p.post_timestamp),1),week(p.post_timestamp, 2 ) * 7 ) as Week, COUNT(p.post_id) as Posts
FROM cl_posts p
GROUP BY Week
ORDER BY WEEK(p.post_timestamp)
我如何也添加评论计数?