Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将 timestampdiff 与最近的日期字段相加,所以我做了什么:
SUM(TIMESTAMPDIFF(SECOND, MAX(date), MAX(date_last_up))) as diff
原来这会触发 MySql 中的错误(组函数的无效使用),我必须删除该MAX()函数才能使其工作:
MAX()
SUM(TIMESTAMPDIFF(SECOND, date, date_last_up)) as diff
有人知道如何使用 MAX() 函数来做到这一点吗?
你可以这样做
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