mysql 按月 季度 统计数据
----按月SELECTcount(id) countNum,MONTH(starttime) starttimeFROM表GROUP BYMONTH(starttime)ORDER BYMONTH(starttime) asc;---按季度SELECTcount(id) countNum,QUARTER(starttime) starttimeFROM表GROUP BYQUARTER(start
·
----按月 (本年)
SELECT
CONCAT(MONTH(createtime),"月") createtime,
CONCAT (count(id),'次') countNum
FROM
表
where
DATE_FORMAT(createtime, '%Y') = date_format( now( ), '%Y' )
GROUP BY
MONTH(createtime)
ORDER BY
MONTH(createtime) asc
---按季度
SELECT
count(id) countNum,
QUARTER(createtime) starttime
FROM
表
GROUP BY
QUARTER(createtime)
ORDER BY
QUARTER(createtime);
更多推荐
已为社区贡献1条内容
所有评论(0)