[原创]mysql进行日统计和月统计的例子


SELECT DATE_FORMAT(FROM_UNIXTIME(uCheckSPassTime),’%Y-%m-%d’) AS d ,COUNT(*) AS so_count FROM `bc_User`
WHERE CheckStates = 2
AND DATE_FORMAT(FROM_UNIXTIME(uCheckSPassTime),’%Y-%m-%d’) BETWEEN ‘2007-11-01’ AND ‘2007-11-30’
GROUP BY DATE_FORMAT(FROM_UNIXTIME(uCheckSPassTime),’%Y-%m-%d’)

SELECT DATE_FORMAT(FROM_UNIXTIME(uCheckSPassTime),’%Y-%m’) AS m ,COUNT(*) AS so_count FROM `bc_User`
WHERE CheckStates = 2
AND DATE_FORMAT(FROM_UNIXTIME(uCheckSPassTime),’%Y-%m’) BETWEEN ‘2007-11’ AND ‘2009-11’
GROUP BY DATE_FORMAT(FROM_UNIXTIME(uCheckSPassTime),’%Y-%m’)



发表评论

电子邮件地址不会被公开。 必填项已用*标注

2 + 8 =