Thankyou kindly Bill. Just to verify, SUM adds up values. My data
is only 1 or 0. I used SUM as an example, the below query you recommend
will count all 'rows' which are 0, thus returning a number which
represents how many 0's were found?

Thankyou for the fast reply,
Calvin

On Thu, 30 Aug 2001, Adams, Bill TQO wrote:

> SELECT SUM( bool_was_connected=1 ) AS was_connected,
> SUM( bool_was_connected=0 ) AS was_not_connected, etc...
>
>
> b.
>
>
> [EMAIL PROTECTED] wrote:
>
> > Evening Gurus,
> >
> >   I have a small problem that I've beaten to death the past 2 days. I am
> > trying to get the value of a row, and update another table accordingly.
> > The data within the row is either a 1 or 0.  My issue is in trying to
> > increment a count for both 1's and 0's.
> >
> >   In other words, I want to SUM up all the 1's and update a table with
> > this sum. I also want to sum up all the 0's and add this total count to
> > the table as well. This can be accomplished in  a long query, or in
> > through a language..what I am trying to accomplish is to get the total sum
> > of each value without using a WHERE clause. Something akin to:
> >
> >     SELECT ...
> >                  SUM(bool_was_connected),
> >                  COUNTNULL(bool_was_connected),
> >     etc...
> >
> > the SUM will sum up all non-null values. The COUNTNULL would sum up all
> > rows which have a value of 0.
> >
> > Does anyone have a UDF for this function? I currently don't have room on
> > my laptop to download the mysql source code in order to write this up. (
> > Also have not written a udf for mysql up to this point either)
> >
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to