Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 07:24 AM
Doug Ly
Guest
 
Posts: n/a
Default 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


  #2  
Old November 12th, 2005, 07:24 AM
Mark A
Guest
 
Posts: n/a
Default Re: SUM a Column contain NULL value

"Doug Ly" <deadlock@dev.null> wrote in message
news:pMqoc.26579$E27.5138@newssvr22.news.prodigy.c om...[color=blue]
> 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
>[/color]
This is a DB2 forum.

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

where col_name not null


  #3  
Old November 12th, 2005, 07:24 AM
Mark A
Guest
 
Posts: n/a
Default Re: SUM a Column contain NULL value

"Doug Ly" <deadlock@dev.null> wrote in message
news:pMqoc.26579$E27.5138@newssvr22.news.prodigy.c om...[color=blue]
> 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
>[/color]
This is a DB2 forum.

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

where col_name not null


  #4  
Old November 12th, 2005, 07:24 AM
Ian
Guest
 
Posts: n/a
Default Re: SUM a Column contain NULL value

Doug Ly wrote:
[color=blue]
> 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[/color]

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! =-----
  #5  
Old November 12th, 2005, 07:24 AM
Leo
Guest
 
Posts: n/a
Default Re: SUM a Column contain NULL value

Have you tried "select sum(coalesce(column,0)) ...."? It won't affect
your sum to add zero.

Ian <ianbjor@mobileaudio.com> wrote in message news:<40a2755e$1_1@corp.newsgroups.com>...[color=blue]
> Doug Ly wrote:
>[color=green]
> > 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[/color]
>
> 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! =-----[/color]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.