我想获得多行之间的时差
Sl_id ID ShortLeave createddate
15 8 2015-10-02 13:10:07 2015-02-11 16:08:01
16 8 2015-10-02 14:05:07 2015-02-11 16:08:01
我需要按where Id=1
获取短假差异过滤器。我试过了
SELECT timediff(A.shortleave,B.shortleave) AS timedifference
FROM shortL A JOIN shortL B ON B.id = A.id
where A.Id=1
group by A.ID,A.ShortLeave ;
但我有两行
'00:00:00'
'00:55:00'
这是因为Sl_id
。所以请帮助我如何获得多行的一行。
答案 0 :(得分:0)
我更改了我的查询
SELECT timediff(A.shortleave,B.shortleave) AS timedifference
FROM shortL A JOIN shortL B ON B.id = A.id
where A.Id=1
group by A.ID,A.ShortLeave order by timedifference desc limit 1;
通过这样做我总是得到最新专栏。在这里我只得到'00:55:00'
,结果没问题。