> 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).
> 
> On the other hand, the following query does return NULL:
> 
> SELECT AVG(b) FROM TEST;
> 

I should think NULL would be the correct result, but it's not what I get:

D:\temp\convention>sqlite3 testnull
SQLite version 3.0.8
Enter ".help" for instructions
sqlite> create table t( b integer, c integer );
sqlite> insert into t(b) values(1);
sqlite> insert into t(b) values(2);
sqlite> insert into t(b) values(3);
sqlite> select * from t;
1|
2|
3|
sqlite> select sum(c) from t;
0
sqlite> select sum(b) from t;
6
sqlite> select count(*) from t where c is null;
3
sqlite>



-- 
---
The Castles of Dereth Calendar: a tour of the art and architecture of 
Asheron's Call
http://www.lulu.com/content/77264

Reply via email to