mysql mean time, top 10 models

-4

Personal as per the illustration in my table below, I would like to get the following data:

✓ Time the POST spent from DATE_ENTRADE to DATE_SAID

✓ Overall average time all POSTS take from DATE_ENTRATE to DATE_SAID

TABELA: OS  
+--------------------------------------------------------------+
| ID | POSTO     | MODELO | DATA_ENTRADA | DATA_SAIDA          |
+--------------------------------------------------------------+
| 1  | SÃO PAULO | FW100  | 2014-11-17   | 2014-11-19 12:59:00 |
+--------------------------------------------------------------+
    
asked by anonymous 19.11.2014 / 16:14

1 answer

1
  

Time the POST spent from DATE_ENTRADE to DATE_SAID

Sum of minutes that POSTO spent:

SELECT SUM(TIMESTAMPDIFF(MINUTE,DATA_ENTRADA,DATA_SAIDA)) AS tempo_total_posto FROM 'OS' WHERE POSTO = 'SÃO PAULO'
  

Overall average time that all POSTS take from DATE_ENTRATE to DATA_DATE

Overall average spend time spent

SELECT AVG(TIMESTAMPDIFF(MINUTE,DATA_ENTRADA,DATA_SAIDA)) AS media_geral FROM 'OS'
    
19.11.2014 / 16:41