我有下表:
ticket arrivaltime resolution time status
t1 '2012-09-03' null new
t2 '2012-09-04' null new
t1 (can be anything) '2012-09-14' verified
t1 (can be anything) '2012-09-16' verified
t2 (can be anything) '2012-09-06' verified
现在我想找出t1天数的差异:
Age(t1)=(resolution time of last entry) - (arrival time of first entry)
同样地,我会在t2找到它。
我怎样才能找到这个?
答案 0 :(得分:0)
您可以执行以下操作:
SELECT TICKET, DATE_DIFF(MAX(RESOLUTION_TIME) - MIN(ARRIVAL_TIME)) AS DIFF FROM TABLE GROUP BY TICKET
答案 1 :(得分:0)
请参阅以下关于语法的链接
Date Difference in MySQL to calculate age
SELECT TICKET, DATE_DIFF(MAX(RESOLUTION_TIME),MIN(ARRIVAL_TIME)) From TABLE