gpt4 book ai didi

mysql - 获取 Chart.js 一年间隔内每个月的 SUM 数据

转载 作者:行者123 更新时间:2023-11-29 17:40:31 24 4
gpt4 key购买 nike

我有一个包含 IP 会计数据的表,

我想获取从当天算起一年内每个月(一月、二月、三月...)的SUM(bytes)

column: bytes <-- bytes

column: timeanddate <-- timestamp

我的查询:

SELECT (SELECT SUM(bytes) FROM ip_accounting);

请帮忙。

最佳答案

我已经找到了我正在寻找的答案

SELECT 
SUM(download_bytes) as download_bytes,
SUM(upload_bytes) as upload_bytes,
SUM(download_bytes + upload_bytes) as total_bytes,
DAY(date) as day,
MONTHNAME(date) as month
FROM
traffic_counters
LEFT JOIN services ON traffic_counters.service_id = services.id
WHERE
date >= (NOW() - INTERVAL 1 MONTH)
GROUP BY
MONTH(date),
DAY(date)
ORDER BY
MONTH(date),
DAY(date)

关于mysql - 获取 Chart.js 一年间隔内每个月的 SUM 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50031771/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com