我想总结一下最近日期字段的时间戳,所以我做了什么:
SUM(TIMESTAMPDIFF(SECOND, MAX(date), MAX(date_last_up))) as diff
原来这会触发MySql中的错误(组函数的使用无效),我不得不删除MAX()
函数才能使它工作:
SUM(TIMESTAMPDIFF(SECOND, date, date_last_up)) as diff
有人知道如何使用MAX()函数吗?
答案 0 :(得分:1)
你可以这样做
select yourcolumn , SUM(TIMESTAMPDIFF(SECOND, max_date, date_last_up))
from (
select yourcolumn , MAX(date) as max_date , MAX(date_last_up) as date_last_up
WHERE ....
)as t
GROUP by yourcolumn