Fórum Tirar média de horas #493547
25/09/2014
0
Estou com uma dúvida muito cruel.
Ainda com aqueles atendimentos. Eu tenho a quantidade de atendimentos que um Atendente fez. Exemplo:
João tem 156 Atendimentos.
E eu também tenho o total de horas que o joão trabalhou em todos os atendimentos. Exemplo:
João tem 156 Atendimentos e 05:59:15 de Tempo Total dos seus Atendimentos.
Como eu faço pra tirar a média de cada atendimento com base nessas informações?
Eu sei que é dividir o total de atendimentos pelo tempo total. Mas como faço isso no Delphi ou pelo próprio select?
Uso Delphi XE
Marlon Minotti
Curtir tópico
+ 0Post mais votado
25/09/2014
select
atendentee as Atendente, total as "Total Atendimentos", Fechadas, Pendentes, Suspensas,
(case when (media/3600) < 10 then 0||(media/3600) else (media/3600) end ||':'||
case when ((media-((media)/3600)*3600)/60) < 10 then 0||((media-((media)/3600)*3600)/60) else ((media-((media)/3600)*3600)/60) end ||':'||
case when (media - (media/3600)*3600 - ((media-((media)/3600)*3600)/60)*60 ) < 10
then '0'||(media - (media/3600)*3600 - ((media-((media)/3600)*3600)/60)*60 ) else
(media - (media/3600)*3600 - ((media-((media)/3600)*3600)/60)*60 ) end) as "Media",
(case when (HORA/3600) < 10 then 0||(HORA/3600) else (HORA/3600) end ||':'||
case when ((HORA-((HORA)/3600)*3600)/60) < 10 then 0||((HORA-((HORA)/3600)*3600)/60) else ((HORA-((HORA)/3600)*3600)/60) end ||':'||
case when (HORA - (HORA/3600)*3600 - ((HORA-((HORA)/3600)*3600)/60)*60 ) < 10
then '0'||(HORA - (HORA/3600)*3600 - ((HORA-((HORA)/3600)*3600)/60)*60 ) else
(HORA - (HORA/3600)*3600 - ((HORA-((HORA)/3600)*3600)/60)*60 ) end) as "Horas Totais"
from(SELECT
atendentee, total, Fechadas, Pendentes, Suspensas, (segundos/total) as media, HORA
from (select s.atendente as atendentee,
count(*) as total,
CAST(SUM(
EXTRACT( HOUR FROM s.hora_total ) * 3600 +
EXTRACT( MINUTE FROM s.hora_total ) * 60 +
EXTRACT( SECOND FROM s.hora_total ))as integer) AS HORA,
CAST(SUM(
EXTRACT( HOUR FROM s.hora_total ) * 3600 +
EXTRACT( MINUTE FROM s.hora_total ) * 60 +
EXTRACT( SECOND FROM s.hora_total ))as integer) AS Segundos,
count(case when s.status = 1 then 1 end) as Fechadas,
count(case when s.status = 0 then 1 end) as Pendentes,
count(case when s.status = 2 then 1 end) as Suspensas
FROM servicos s where 1=1 and s.atendente like 'EDEMI%' group by s.atendente))
Marlon Minotti
Gostei + 1
Mais Posts
25/09/2014
Fabiano Carvalho
Se for SQL Server, basta converter as horas para float e realizar a operacao e depois voltar para datetime.
Gostei + 0
25/09/2014
Marlon Minotti
Gostei + 0
25/09/2014
Marlon Minotti
Gostei + 0
25/09/2014
Marlon Minotti
Se tiver alguma função no firebird que faça isso, eu agradeço. No mysql pelo que pesquisei tem um jeito de fazer +- assim:
SELECT SEC_TO_TIME(TIME_TO_SEC('12:30:45') / 10)
No Firebird tem algo parecido?
Gostei + 0
25/09/2014
Fabiano Carvalho
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)