Subject | Re: Summiing Amounts |
---|---|
Author | moegie2 |
Post date | 2005-12-01T11:24:56Z |
even better! :)
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
>
> --- In firebird-support@yahoogroups.com, Adomas Urbanavicius wrote:
> > select
> > date,
> > item,
> > sum(amount)
> > from mytable
> > group by date,item,
> > (
> > case when amount > 0 THEN 1
> > ELSE
> > 0
> > END
> > )
>
> or make a small change to get it on the same line:
>
> select datecolumn, item,
> sum(case when amount > 0 then amount else 0) as posamt,
> sum(case when amount < 0 then -amount else 0) as negamt
> group by datecolumn, item
>
> HTH,
> Set
>