Problema com select duplicando valor?
Eu acertei o select usando um subselect então o TITULO deste post
Problema com select duplicando valor?
Não existe mais
Como não consegui alterar o titulo do post, mudei somente o conteudo do post.
O titulo deveria ser este agora
Como somar total de horas no firebird?
Pessoal estou usando fb 2.0 e preciso saber como somar total de horas no firebird?
select td.idcondutor, td.nomecondutor,
--sum(xd.horatotal) Total_Horas,
sum(xd.kms) Total_KM, count(xd.descrserv) Quantidade_Servicos,
coalesce(sum(xd.vrlcondutor),0) Total_Codutor,
(select coalesce(sum(vl.valor),0)
from vale vl where td.idcondutor = vl.idfunciona
and coalesce(vl.fechamov,'',null) <> 'F')as Total_Despesa
from ordemserv td
inner join servicos xd on
td.idordem = xd.idordem and
td.nomecondutor = xd.nomecondutor
where td.nomecondutor = xd.nomecondutor
and td.idcondutor between :idCondIni and :idCondFin
and td.nomecondutor is not null
and td.idordem = xd.idordem
and td.emissao between :tddataini and :tddatafin
group by td.idcondutor, td.nomecondutor
O comando SUM não é reconhecido para somar total de horas no fb, então como devo fazer?
O campo HORATOTAL é um campo tipo TIME.
Problema com select duplicando valor?
Não existe mais
Como não consegui alterar o titulo do post, mudei somente o conteudo do post.
O titulo deveria ser este agora
Como somar total de horas no firebird?
Pessoal estou usando fb 2.0 e preciso saber como somar total de horas no firebird?
select td.idcondutor, td.nomecondutor,
--sum(xd.horatotal) Total_Horas,
sum(xd.kms) Total_KM, count(xd.descrserv) Quantidade_Servicos,
coalesce(sum(xd.vrlcondutor),0) Total_Codutor,
(select coalesce(sum(vl.valor),0)
from vale vl where td.idcondutor = vl.idfunciona
and coalesce(vl.fechamov,'',null) <> 'F')as Total_Despesa
from ordemserv td
inner join servicos xd on
td.idordem = xd.idordem and
td.nomecondutor = xd.nomecondutor
where td.nomecondutor = xd.nomecondutor
and td.idcondutor between :idCondIni and :idCondFin
and td.nomecondutor is not null
and td.idordem = xd.idordem
and td.emissao between :tddataini and :tddatafin
group by td.idcondutor, td.nomecondutor
O comando SUM não é reconhecido para somar total de horas no fb, então como devo fazer?
O campo HORATOTAL é um campo tipo TIME.
Adriano Dolce
Curtidas 0
Respostas
Adriano Dolce
11/04/2010
Fiz assim
select td.idcondutor, td.nomecondutor,
sum(xd.kms) Total_KM, count(xd.descrserv) Quantidade_Servicos,
coalesce(sum(xd.vrlcondutor),0) Total_Codutor,
(select
(hora/3600) ||':'||
((hora-((hora)/3600)*3600)/60)||':'||
(hora - (hora/3600)*3600 - ((hora-((hora)/3600)*3600)/60)*60 )
from
(
select
cast(sum(
extract( hour from xd.horatotal ) * 3600 +
extract( minute from xd.horatotal ) * 60 +
extract( second from xd.horatotal )
) as integer) as hora
from servicos xd
where td.idordem = xd.idordem and
td.nomecondutor = xd.nomecondutor))as Total_Horas,
(select coalesce(sum(vl.valor),0)
from vale vl where td.idcondutor = vl.idfunciona
and coalesce(vl.fechamov,'',null) <> 'F')as Total_Despesa
from ordemserv td
inner join servicos xd on
td.idordem = xd.idordem and
td.nomecondutor = xd.nomecondutor
where td.nomecondutor = xd.nomecondutor
and td.idcondutor between :idCondIni and :idCondFin
and td.nomecondutor is not null
and td.idordem = xd.idordem
and td.emissao between :tddataini and :tddatafin
group by td.idcondutor, td.nomecondutor
Mais esta formatando meio estranho a hora
Está saindo assim
1:9:0
4:0:0
Queria que formatasse para sair assim (os segundos não tem necessidade)
01:09
04:00
etc..
se for por exemplo mais de 23:59 horas vai somando
120:40
200:55
etc...
Este select deve trazer o total de horas que o funcionario fez durante o periodo da clausula where.
select td.idcondutor, td.nomecondutor,
sum(xd.kms) Total_KM, count(xd.descrserv) Quantidade_Servicos,
coalesce(sum(xd.vrlcondutor),0) Total_Codutor,
(select
(hora/3600) ||':'||
((hora-((hora)/3600)*3600)/60)||':'||
(hora - (hora/3600)*3600 - ((hora-((hora)/3600)*3600)/60)*60 )
from
(
select
cast(sum(
extract( hour from xd.horatotal ) * 3600 +
extract( minute from xd.horatotal ) * 60 +
extract( second from xd.horatotal )
) as integer) as hora
from servicos xd
where td.idordem = xd.idordem and
td.nomecondutor = xd.nomecondutor))as Total_Horas,
(select coalesce(sum(vl.valor),0)
from vale vl where td.idcondutor = vl.idfunciona
and coalesce(vl.fechamov,'',null) <> 'F')as Total_Despesa
from ordemserv td
inner join servicos xd on
td.idordem = xd.idordem and
td.nomecondutor = xd.nomecondutor
where td.nomecondutor = xd.nomecondutor
and td.idcondutor between :idCondIni and :idCondFin
and td.nomecondutor is not null
and td.idordem = xd.idordem
and td.emissao between :tddataini and :tddatafin
group by td.idcondutor, td.nomecondutor
Mais esta formatando meio estranho a hora
Está saindo assim
1:9:0
4:0:0
Queria que formatasse para sair assim (os segundos não tem necessidade)
01:09
04:00
etc..
se for por exemplo mais de 23:59 horas vai somando
120:40
200:55
etc...
Este select deve trazer o total de horas que o funcionario fez durante o periodo da clausula where.
GOSTEI 0
Adriano Dolce
11/04/2010
Acho que em cada conta (antes de concatenar com ':')
verificar (usando um case) se o valor é menor que 10, se for, concatena
com '0' (antes do número).
Mais como fazer este case antes?
Mais como fazer este case antes?
select td.idcondutor, td.nomecondutor, sum(xd.kms) Total_KM, count(xd.descrserv) Quantidade_Servicos, coalesce(sum(xd.vrlcondutor),0) Total_Codutor, (select
case hora
when < '10' then '0'
end as hora, (hora/3600) ||':'|| ((hora-((hora)/3600)*3600)/60)||':'|| (hora - (hora/3600)*3600 - ((hora-((hora)/3600)*3600)/60)*60 ) from ( select cast(sum( extract( hour from xd.horatotal ) * 3600 + extract( minute from xd.horatotal ) * 60 + extract( second from xd.horatotal ) ) as integer) as hora from servicos xd where td.idordem = xd.idordem and td.nomecondutor = xd.nomecondutor))as Total_Horas, (select coalesce(sum(vl.valor),0) from vale vl where td.idcondutor = vl.idfunciona and coalesce(vl.fechamov,'',null) <> 'F')as Total_Despesa from ordemserv td inner join servicos xd on td.idordem = xd.idordem and td.nomecondutor = xd.nomecondutor where td.nomecondutor = xd.nomecondutor and td.idcondutor between :idCondIni and :idCondFin and td.nomecondutor is not null and td.idordem = xd.idordem and td.emissao between :tddataini and :tddatafin group by td.idcondutor, td.nomecondutor
GOSTEI 0
Adriano Dolce
11/04/2010
Acho que ja acertei esta pendência.
select td.idcondutor, td.nomecondutor, sum(xd.kms) Total_KM, count(xd.descrserv) Quantidade_Servicos, coalesce(sum(xd.vrlcondutor),0) Total_Codutor, (select 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 from ( select cast(sum( extract( hour from xd.horatotal ) * 3600 + extract( minute from xd.horatotal ) * 60 + extract( second from xd.horatotal ) ) as integer) as hora from servicos xd where td.idordem = xd.idordem and td.nomecondutor = xd.nomecondutor))as Total_Horas, (select coalesce(sum(vl.valor),0) from vale vl where td.idcondutor = vl.idfunciona and coalesce(vl.fechamov,'',null) <> 'F')as Total_Despesa from ordemserv td inner join servicos xd on td.idordem = xd.idordem and td.nomecondutor = xd.nomecondutor where td.nomecondutor = xd.nomecondutor and td.idcondutor between :idCondIni and :idCondFin and td.nomecondutor is not null and td.idordem = xd.idordem and td.emissao between :tddataini and :tddatafin group by td.idcondutor, td.nomecondutor
GOSTEI 0
Carlos Mazzi
11/04/2010
Resolvido ?
GOSTEI 0