論壇常用統計 MySQL 語句代碼

mysql> select Year(from_unixtime(user_regdate)) as Year, Month(from_unixtime(user_regdate)) as Month, count(*) as Total from phpbb_users group by Year,Month;

Quote:
+------+-------+-------+ 
| Year | Month | Total | 
+------+-------+-------+ 
| 2011 | 1 | 5070 | 
| 2011 | 2 | 3638 | 
| 2011 | 3 | 6872 | 
| 2011 | 4 | 5653 | 
| 2011 | 5 | 5135 | 
| 2011 | 6 | 3893 | 
| 2011 | 7 | 3888 | 
| 2011 | 8 | 4265 | 
| 2011 | 9 | 4220 | 
| 2011 | 10 | 5109 | 
| 2011 | 11 | 4833 | 
| 2011 | 12 | 3939 |


每月發貼量統計
mysql> select Year(from_unixtime(post_time)) as Year, Month(from_unixtime(post_time)) as Month, count(*) as Total from phpbb_posts group by Year,Month;

Quote:
+------+-------+-------+ 
| Year | Month | Total | 
+------+-------+-------+ 
| 2011 | 1 | 25872 | 
| 2011 | 2 | 18970 | 
| 2011 | 3 | 30976 | 
| 2011 | 4 | 44627 | 
| 2011 | 5 | 51682 | 
| 2011 | 6 | 38707 | 
| 2011 | 7 | 33571 | 
| 2011 | 8 | 37805 | 
| 2011 | 9 | 29904 | 
| 2011 | 10 | 37508 | 
| 2011 | 11 | 34602 | 
| 2011 | 12 | 27689 |


每月流失人數,第一列爲註冊後沒有一次訪問的。
mysql> select Year(from_unixtime(user_lastvisit)) as Year, Month(from_unixtime(user_lastvisit)) as Month, count(*) as Total from phpbb_users group by Year,Month;

Quote:
+------+-------+-------+ 
| Year | Month | Total | 
+------+-------+-------+ 
| 2011 | 1 | 5694 | 
| 2011 | 2 | 4072 | 
| 2011 | 3 | 7269 | 
| 2011 | 4 | 6931 | 
| 2011 | 5 | 7135 | 
| 2011 | 6 | 5286 | 
| 2011 | 7 | 5028 | 
| 2011 | 8 | 5534 | 
| 2011 | 9 | 5718 | 
| 2011 | 10 | 7753 | 
| 2011 | 11 | 7806 | 
| 2011 | 12 | 8115 |


用戶持續人數,第一列爲註冊後沒有一次訪問的。
mysql> select Year(from_unixtime(user_lastvisit-user_regdate))-1970 as Year, Month(from_unixtime(user_lastvisit-user_regdate)) as Month, count(*) as Total from phpbb_users group by Year,Month;

Quote:
+------+-------+--------+ 
| Year | Month | Total | 
+------+-------+--------+ 
| NULL | NULL | 46225 | 
| 0 | 1 | 174706 | 
| 0 | 2 | 13594 | 
| 0 | 3 | 9179 | 
| 0 | 4 | 6460 | 
| 0 | 5 | 5464 | 
| 0 | 6 | 5000 | 
| 0 | 7 | 4617 | 
| 0 | 8 | 4018 | 
| 0 | 9 | 3511 | 
| 0 | 10 | 3311 | 
| 0 | 11 | 3072 | 
| 0 | 12 | 3499 |


按小時統計發貼數:
mysql> select Hour(from_unixtime(post_time)) as Hour, count(*) as Total from phpbb_posts group by Hour;

Quote:
+------+--------+ 
| Hour | Total | 
+------+--------+ 
| 0 | 83908 | 
| 1 | 44779 | 
| 2 | 24445 | 
| 3 | 14259 | 
| 4 | 9270 | 
| 5 | 7562 | 
| 6 | 10765 | 
| 7 | 23244 | 
| 8 | 65756 | 
| 9 | 120357 | 
| 10 | 149681 | 
| 11 | 155670 | 
| 12 | 150173 | 
| 13 | 152288 | 
| 14 | 137075 | 
| 15 | 139858 | 
| 16 | 154391 | 
| 17 | 151045 | 
| 18 | 136296 | 
| 19 | 146210 | 
| 20 | 162984 | 
| 21 | 181658 | 
| 22 | 179757 | 
| 23 | 137208 | 
+------+--------+

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章