Subject | Re: Summiing Amounts |
---|---|
Author | Svein Erling Tysvær |
Post date | 2005-12-01T11:19:07Z |
--- In firebird-support@yahoogroups.com, Adomas Urbanavicius wrote:
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
> selector make a small change to get it on the same line:
> date,
> item,
> sum(amount)
> from mytable
> group by date,item,
> (
> case when amount > 0 THEN 1
> ELSE
> 0
> END
> )
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