473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SUM a Column contain NULL value

Hi,
I use WinSQL to execute a query. It takes the sum of a column. Within the
column, there are several NULL values and winSQL complains that it cannot
add NULL values.

Does anybody have an idea how to get it work? Thanks
Nov 12 '05 #1
4 12281
"Doug Ly" <de******@dev.null> wrote in message
news:pM******************@newssvr22.news.prodigy.c om...
Hi,
I use WinSQL to execute a query. It takes the sum of a column. Within the
column, there are several NULL values and winSQL complains that it cannot
add NULL values.

Does anybody have an idea how to get it work? Thanks

This is a DB2 forum.

But you might try adding a where clause, such as:

where col_name not null
Nov 12 '05 #2
"Doug Ly" <de******@dev.null> wrote in message
news:pM******************@newssvr22.news.prodigy.c om...
Hi,
I use WinSQL to execute a query. It takes the sum of a column. Within the
column, there are several NULL values and winSQL complains that it cannot
add NULL values.

Does anybody have an idea how to get it work? Thanks

This is a DB2 forum.

But you might try adding a where clause, such as:

where col_name not null
Nov 12 '05 #3
Ian
Doug Ly wrote:
Hi,
I use WinSQL to execute a query. It takes the sum of a column. Within the
column, there are several NULL values and winSQL complains that it cannot
add NULL values.

Does anybody have an idea how to get it work? Thanks


SELECT SUM(column) ...

SUM(), as documented in the SQL Reference, ignores NULL values in the column.


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 12 '05 #4
Leo
Have you tried "select sum(coalesce(column,0)) ...."? It won't affect
your sum to add zero.

Ian <ia*****@mobileaudio.com> wrote in message news:<40**********@corp.newsgroups.com>...
Doug Ly wrote:
Hi,
I use WinSQL to execute a query. It takes the sum of a column. Within the
column, there are several NULL values and winSQL complains that it cannot
add NULL values.

Does anybody have an idea how to get it work? Thanks


SELECT SUM(column) ...

SUM(), as documented in the SQL Reference, ignores NULL values in the column.


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ken1 | last post by:
I am going to drop a primary key from one column and create a new column to be used as primary key in an existing database. The old column was a date column which someone earlier though was a good...
4
by: Brian Brane | last post by:
I have properties that wrap DataRow columns as in: public int aNumber { get{ return m_DataRow; } set{ m_DataRow = value; } } If the column happens to contain DBNull, I get a cast exception...
26
by: Martin R | last post by:
Hi, How to find first not null value in column whitout chacking whole table (if there is a not null value then show me it and stop searching, the table is quite big)? thx, Martin *** Sent...
5
by: GG | last post by:
I am trying to add a nullable datetime column to a datatable fails. I am getting exception DataSet does not support System.Nullable<>. None of these works dtSearchFromData.Columns.Add( new...
8
by: shorti | last post by:
DB2 V8.2 on AIX I am looking for an efficient way to update several columns in a table that will have a default change. The problem is the table is large (million records) and there are 1 to 4...
13
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I want to create a new column in a datatable from two existing columns. I have no problem to create the new column using the datatable.columns.add method. The problem is the value of the new...
0
by: JohnMcA | last post by:
Hi, I'm having problems accessing values in an Excel spreadsheet column which contain a ; delimiter. If there is only one value in the column, then it is correctly returned without any problem. ...
2
by: semomaniz | last post by:
I was able to combine three columns with following sql statement but the problem that i am having is if one of the column has a null value the concatenation does not work and the sql statement does...
6
by: blanderk | last post by:
Dear all, i need some help here. currently i have 1 table with multiple field. 1 of the field name PackSize contain data like ;;5000;ml;; or ;;;;60;Tablet etc. So, i want to ask expert out...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.