0

我有这个 MySQL 查询,它告诉我状态更改条目之间的区别:

SELECT 
    t1.`TRACKID` AS TicketNumber,
    TIMEDIFF(t2.`date`, t1.`date`) AS Difference
FROM
    hesk_history t1
    JOIN hesk_history t2 ON t2.`TRACKID` = t1.`TRACKID` AND t1.`Action` = 'Created' AND (t2.`Action` = 2)

给我以下结果集:

TicketNumber    Difference
2013-08-12-36   410:21:25
2013-06-12-91   00:01:22
2013-08-12-50   00:00:26

然后我如何对这个结果集进行 AVG 处理?

4

1 回答 1

0

http://www.w3schools.com/sql/sql_func_avg.asp 所以在你的情况下

SELECT AVG(t1. TRACKIDAS TicketNumber, TIMEDIFF(t2. date, t1. date)) AS Difference FROM hesk_history t1 JOIN hesk_history t2 ON t2. TRACKID= t1。TRACKID和 t1。Action= '创建' AND (t2. Action= 2)

于 2013-08-12T23:48:03.943 回答