【发布时间】:2012-12-06 14:58:31
【问题描述】:
我有以下两张表:
帖子
- post_id
- post_title
- post_timestamp
评论
- comment_id
- posts_post_id
- comment_content
- comment_timestamp
我想创建一个显示每周发帖数和评论数的报告。像这样的:
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)
如何添加评论计数?
【问题讨论】: