Just for information:

Oracle returns NULL's in both cases: for SUM() and for
AVG().

I checked it for ver. 8.1.7 and 9.2.0



--- "D. Richard Hipp" <[EMAIL PROTECTED]> wrote:

> On Thu, 2005-09-08 at 10:24 -0700, Will Leshner
> wrote:
> > Say I have a column called 'b' in a table called
> 'test' and every  
> > field in 'b' has a NULL value. What is the
> expected behavior of the  
> > following query:
> > 
> > SELECT SUM(b) FROM TEST;
> > 
> > I guess I'm thinking I'll get back NULL. Instead I
> get 0 (or, in the  
> > 3.2.5 code, 0.0).
> > 
> 
> SUM ignores NULLs.  So if it ignores everything, it
> returns the
> sum of nothing, which is 0.  (Not the 0.0 issue is
> fixed in CVS HEAD.)
> 
> > On the other hand, the following query does return
> NULL:
> > 
> > SELECT AVG(b) FROM TEST;
> > 
> 
> AVG is implemented as SUM/COUNT.  But the count is
> zero.  So
> you get a NULL.
> -- 
> D. Richard Hipp <[EMAIL PROTECTED]>
> 
> 

Reply via email to