Subject Re: [firebird-support] adding positive and negative values in differents columns
Author Sergio H. Gonzalez
Something wrong with my question? probably in not too clear... All I'd like to
know if this is the *best* way of slpitting a sum column in two, acording on its
value (> 0 or < 0)

Thanks, and sorry if I'm not clear enough!!

> SELECT
> D.id,
> Sum(case when D.importe > 0
> then D.importe
> else 0 end) as positive,
> Sum(case when D.importe < 0
> then Abs(D.importe)
> else 0 end) as negative
> FROM
> MyTable D
> GROUP BY
> D.id
> ORDER BY
> D.id