我在同一分钟的mysql表中有很多值,我想选择avg值来显示每分钟的单个值:
DEBIT 2018-02-15 09:22:00 54.8611
DEBIT 2018-02-15 09:22:00 45.4861
DEBIT 2018-02-15 09:22:00 51.7361
DEBIT 2018-02-15 09:22:00 83.3333
DEBIT 2018-02-15 09:23:00 135.764
DEBIT 2018-02-15 09:23:00 134.722
DEBIT 2018-02-15 09:23:00 135.764
DEBIT 2018-02-15 09:24:00 135.417
DEBIT 2018-02-15 09:24:00 135.069
DEBIT 2018-02-15 09:24:00 133.681
DEBIT 2018-02-15 09:25:00 134.375
DEBIT 2018-02-15 09:25:00 134.375
DEBIT 2018-02-15 09:25:00 133.681
输出:
DEBIT APA RACIRE SCALAT 2018-02-15 09:22:00 88.8611
DEBIT APA RACIRE SCALAT 2018-02-15 09:23:00 148.542
DEBIT APA RACIRE SCALAT 2018-02-15 09:24:00 135.875
DEBIT APA RACIRE SCALAT 2018-02-15 09:25:00 134.611
答案 0 :(得分:0)
assumin your_date是您可以按HOUR(your_date), MINUTE(Your_date)
select DATE(your_date), HOUR(your_date), MINUTE(Your_date), AVG(your_value)
from your_table
GROUP BY DATE(your_date), HOUR(your_date), MINUTE(Your_date)
答案 1 :(得分:0)
尝试通过适当调用DATE_FORMAT
进行汇总:
SELECT
DATE_FORMAT(date, '%Y,%m,%d %h,%i'),
AVG(TEMP) AS avg_temp
FROM yourTable
GROUP BY DATE_FORMAT(date, '%Y,%m,%d %h,%i');