Php 在一个表中计算两天或三天之间的天数

Php 在一个表中计算两天或三天之间的天数,php,mysql,sql,Php,Mysql,Sql,我有一个名为transaction_detail的表,其中包含id_transd、id_trans、id_cust和inputtime id_transd | id_trans | id_cust | inputtime | 1 | 1 | 1 | 2013-04-15 16:55:58 | 2 | 1 | 1 | 2013-05-15 16:55:58 | 3

我有一个名为transaction_detail的表,其中包含id_transd、id_trans、id_cust和inputtime

  id_transd | id_trans | id_cust | inputtime           |
  1         | 1        | 1       | 2013-04-15 16:55:58 | 
  2         | 1        | 1       | 2013-05-15 16:55:58 | 
  3         | 1        | 1       | 2013-06-15 16:55:58 |
  4         | 2        | 2       | 2013-06-15 16:55:58 | 
  ...
我想获得具有相同id_cust和id_trans的输入时间量。
例如:当管理员想要计算在一个客户上完成的工作的时间时,管理员需要单击客户的名称,系统将计算日期

 |No.| Name     | Process     | Time                |
 |1. | D-net    | by sales    | 2013-04-15 16:55:58 |
 |   |          | by sadmin   | 2013-05-15 16:55:58 |
 |   |          | by technic  | 2013-06-15 16:55:58 |
我试过这个密码

SELECT t.* datediff(DAY, t.inputtime, nextdate) AS Days_Between
FROM
  (SELECT t.*,
    (SELECT min(inputtime)
      FROM transaksi_detail t2
      WHERE t.id_cust = t2.id_cust
        AND t.id_trans = t2.id_trans
        AND t.inputtime < t2.inputtime) AS nextdate
   FROM transaction_detail t)t
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in F:\htdocs\indosat2\hitung_tanggal2.php on line 20