title: Sum of timeStamp in Mysql
body: <blockquote>
    <p>I'm trying to get the average of Completed time, so at first, I'm getting the completed time of individual processOrders.</p>
  </blockquote>
  
  <p>below Query will get the Completed time for Individual processOrders. </p>
  
  <pre><code>select processorder_prod_number,ifnull(time(round( timediff(max(completed_time), 
  min(start_time)))) ,'00:00:00') as `completedtime`
  from processorder_prod where week(start_time)=week(curdate())
  group by processorder_prod_number;
  </code></pre>
  
  <p>Output is like this</p>
  
  <pre><code>+--------------------+----------------+
  | processorder_number| completedtime  | 
  +--------------------+----------------+
  |   1002135897       |  01:42:15      |
  |   1002135898       |  01:39:43      |
  |   1002135900       |  05:31:52      |
  |   1002135901       |  02:31:52      |
  +--------------------+----------------+
  </code></pre>
  
  <p>when I tried to get the total time, i.e sum(completedtime), it's getting the wrong output.</p>
  
  <pre><code>select count(distinct processorder_prod_number),time(round(sum(completedtime))) as totaltime from
  (select processorder_prod_number,ifnull(time(round( timediff(max(completed_time), 
  min(start_time)))) ,'00:00:00') as `completedtime`
  from processorder_prod where week(start_time)=week(curdate())
  group by processorder_prod_number) as t;
  </code></pre>
  
  <p>Output from above query</p>
  
  <pre><code>+---------------------------+----------------+
  | count(processorder_number)| completedtime  | 
  +---------------------------+----------------+
  |   4                       |   01:42:15     |
  +---------------------------+----------------+
  </code></pre>
  
  <p>please help me where I'm doing wrong.Any suggestions and corrections welcomed, thanks in advance.</p>