mysql medium time, top 10 templates

Asked

Viewed 150 times

-4

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

Time the POST spent from DATA_ENTRADA to DATA_SAÍDA

Overall average time that all STATIONS take from DATA_ENTRADA to DATA_SAÍDA

TABELA: OS  
+--------------------------------------------------------------+
| ID | POSTO     | MODELO | DATA_ENTRADA | DATA_SAIDA          |
+--------------------------------------------------------------+
| 1  | SÃO PAULO | FW100  | 2014-11-17   | 2014-11-19 12:59:00 |
+--------------------------------------------------------------+
  • Test and see if it works properly.

  • yes @Jorgeb. tested and apparently works

  • 5

    @Hugo What doubt remains then?

  • That is, why do you doubt that your logic is incorrect? If the only question is about the TOP 10 (item 3), because quote POSTO and POSTOS (item 1 and 2)?

  • @Thomas edited the post, see if you can understand me

  • @brasofilo better now?

  • @Hugo Could you put the table name in the question too? To help in the examples of who will give the answer.

  • 3

    Okay, what you’d like seems clear, I think it remains now to say what you tried and what problems you had trying to implement. If not, it looks like you’re asking them to do the job for you.

  • @Thomas made ;)

  • Next time Hugo, or even this one (editing), try to demonstrate what you did. Then put the doubt.

Show 5 more comments

1 answer

1


Time the POST spent from DATA_ENTRADA to DATA_SAÍDA

Sum of minutes that such a POST has 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 STATIONS take from DATA_ENTRADA to DATA_SAÍDA

Overall average time of minutes spent

SELECT AVG(TIMESTAMPDIFF(MINUTE,DATA_ENTRADA,DATA_SAIDA)) AS media_geral FROM `OS`
  • 2 questions, sometimes the difference of DATA_ENTRADA and DATA_SAIDA is days, could you convert minutes into days in php? Another how to list the result on all lines not only by specifying the post

  • @Hugo 1) Daria, just divide: $dias = ($minutos / 60) / 24; or change the function parameter TIMESTAMPDIFF of MINUTE for DAY. 2) Just remove the WHERE POSTO... Another thing, I recommend that if you’re a beginner, don’t be afraid to ask more questions in the O.R., but don’t keep using this question for anything other than the original statement, because it harms the community.

  • my buddy thanks for the tip

Browser other questions tagged

You are not signed in. Login or sign up in order to post.