[firebase-br] SQL

Daniel Sonda daniel em mhnet.com.br
Qua Nov 19 11:23:36 -03 2008


Acho que vc vai ter que fazer um sub-select...

select
  MOV.ano,
  MOV.mes,
  MOV.tipomov,
  FUNC .setor,
  sum(MOV.vale) as tot_vale,
  (select sum(movimentacao.total)
    from movimentacao
    left outer join funcionarios on (movimentacao.funcionario = 
funcionarios.codigo)
    where (movimentacao.ano = MOV.ano)
      and (movimentacao.mes = MOV.mes)
      and (movimentacao.tipomov = MOV.tipomov)
      and (movimentacao.total > 0)
      and (funcionarios.setor = FUNC.setor)) as tot_liq
from movimentacao  MOV
left join funcionarios FUNC on (MOV.funcionario = FUNC .codigo)
group by MOV.ano, MOV.mes, MOV.tipomov, FUNC .setor
order by FUNC .setor

Att.
Daniel Sonda
www.h2jsolucoes.com.br





Mais detalhes sobre a lista de discussão lista