0

所以我有这个查询:

SELECT ABS(
    TIMESTAMPDIFF(MINUTE, NOW(),  
        (SELECT MAX(`Time`) FROM ddHistorical WHERE ID = '5')  
    )
)

我想在我的数据库中的每个 ID 上运行它,我该怎么做?

4

2 回答 2

1

这有效(http://www.sqlfiddle.com/#!2/e8ac0/3/0

  SELECT Abs(Timestampdiff(minute, Now(), (SELECT Max( ` time ` ) 
                                         FROM   ddhistorical 
                                         WHERE  id = a.id 
                                         GROUP  BY id))) 
FROM   ddhistorical AS A 
GROUP  BY id 
于 2013-08-29T17:39:59.047 回答
0

尝试这个:-

SELECT ABS(TIMESTAMPDIFF(MINUTE, NOW(), (SELECT MAX(`Time`) FROM ddHistorical
于 2013-08-29T17:21:45.573 回答