是否可以进行一个简单的查询来计算我在确定的时间段内(例如年、月或日)有多少记录,具有 TIMESTAMP
字段,例如:
Is it possible to make a simple query to count how many records I have in a determined period of time like a year, month, or day, having a TIMESTAMP
field, like:
SELECT COUNT(id)
FROM stats
WHERE record_date.YEAR = 2009
GROUP BY record_date.YEAR
甚至:
SELECT COUNT(id)
FROM stats
GROUP BY record_date.YEAR, record_date.MONTH
要有月度统计数据.
谢谢!
GROUP BY YEAR(record_date), MONTH(record_date)
查看日期和时间MySQL 中的函数.
这篇关于MySQL查询GROUP BY日/月/年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!