> Hi,
>
[quoted text clipped - 3 lines]
> sum(items)=0 (div/0 error) so I'd like to use if sum(items)=0 display 0 or
> NULL otherwise calculate the expression.
IDS (7.30/9.20 and later) has both CASE and DECODE, RTFineM. This may also
be a job for a pure SQL HAVING clause.
SELECT key, sum(field)/sum(items)
FROM ...
WHERE ...
GROUP BY key
HAVING sum(item) > 0;
Art S. Kagel
Curtis Crowson - 31 Mar 2004 21:33 GMT
> > Hi,
> >
[quoted text clipped - 14 lines]
>
> Art S. Kagel
having sum(item) <> 0; ;-)
select
key,
case of
when sum(items) != 0 then sum(field)/sum(items)
else null
end
from ...
where ...
group by key
;