我有2個MySQL表(用戶和評論) - 我想要做的是獲取一個報告,讓我有多少用戶作出1評論,有多少用戶作出2評論,有多少用戶發表了3條評論,有多少用戶發表了4條評論,按月份和年份分組。mysql查詢(根據他們的活動提取用戶數)
我有這樣的查詢來獲取的,通過年度區分每個用戶提出的意見數量/月
select year(c.datecreated) as comment_year, month(c.datecreated) as comment_month,
count(c.id) as num_comments
from tblcomments c
inner join tbluser u on u.id = c.userid
where
c.datecreated <= '2013-02-19' and c.datecreated >= '2012-03-01'
group by c.userid, year(c.datecreated), month(c.datecreated)
如何修改這個查詢給我我想要的結果嗎?
太棒了,謝謝! – 2013-02-19 16:46:47