软件吧-RJ8.NET
Home
Ansible
AWS
DevOps
Kubernetes
Monitoring
Terraform
Personal Blog
Focus on IT technology knowledge learning and sharing
Main page
Kubernetes
Main content
Mysql按月度汇总怎么写?
September 17, 2024
7hotness
0likes
0comments
如果时间字段是正常的时间格式:
本文隐藏内容 - 星球会员可见
SELECT
MONTH
(
日期列名
)
AS month,
SUM
(
你要统计的数据的列名
)
AS total
FROM table_name
GROUP BY month;
如果时间字段是int类型的时间戳格式:
本文隐藏内容 - 星球会员可见
SELECT
DATE_FORMAT
(
FROM_UNIXTIME
(
createtime
)
,
'%Y-%m'
)
AS month,
SUM
(
score
)
AS total
FROM table_name
GROUP BY month;
TimLi
This person is a lazy dog and has left nothing
Like
< Last article
Comments
Cancel
Δ
Archives
September 2024
March 2024
Categories
DevOps
Kubernetes
Linux
PHP
ServiceNow
Comments