Grato Marcone!
Funcionou! Era exatamente isso que eu queria.

Sds,

Paulo

Em 03/01/2012 10:26, Marcone escreveu:
>> Estou precisando obter totalização de lotes desde que nenhum item do lote
>> contenha valor zero (o que causa zero como total do lote)
> Não entendi essa lógica mas vou abstrair isso. Eu faria o seguinte:
>
> select lote,
>       sum(valor) as Total
> from lotes_tmp l
> where not exists(select lote
>                from lotes_tmp
>                where lote = l.lote
>                       and valor = 0.0)
> group by lote
> union all
> select lote,
>       valor
> from lotes_tmp
> where valor = 0.0
> group by lote, valor
> order by lote;
>
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a