sum with null value



Hi! I've got problem with sql statement..

in dataset like
col1 col2
a 1
b 3
c 5
d null
e 2

i must to sum col2, but if 1 single value of this column is null then sum
must result to null, according this i wrote statement:

select sum(col2) from table1

but this query results with 11.

any idea??!!

create table table1 (col1 char(1), col2 number);



insert into table1 values('a',1);

insert into table1 values('b',3);

insert into table1 values('c',5);

insert into table1 values('d',null);

insert into table1 values('e',2);



commit;



select sum(col2) from table1;


.



Relevant Pages

  • Re: sum with null value
    ... i must to sum col2, but if 1 single value of this column is null then sum ... insert into table1 values; ... Best regards ...
    (comp.databases.oracle.misc)
  • Re: sum with null value
    ... T schrieb: ... i must to sum col2, but if 1 single value of this column is null then sum must result to null, according this i wrote statement: ... insert into table1 values; ...
    (comp.databases.oracle.misc)
  • Re: Displaying row no/Record Counting
    ... EnteredOn Date/Time when the record was added. ... You create a query that contains Table1. ... On each row of your query, you need to count the number of records in Table1 ... In> order to generate an alphabetical listing of these people,> I have to analyze the report in Excel and sort the> spreadsheet based on the client's name. ...
    (microsoft.public.access.queries)
  • Re: How to add to a new field based on information in existing field?
    ... a query to join the two tables. ... For example, Table1 includes fields TestID ... Table2 includes fields Description and DescriptionFr. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Non-updateable query issue
    ... You have an unnormalized table (of course, as it came from a flat spreadsheet instead of a relational source), and is it has 100 columns. ... joined to the master, showing all the records, the query is not updateable. ... > Say Fred deletes record 79 from Table1, and then Betty changes the> phone ... > Allen Browne - Microsoft MVP. ...
    (microsoft.public.access.queries)