[AccessD] Count multiple columns

Andy Lacey andy at minstersystems.co.uk
Tue Dec 4 08:20:19 CST 2012


Wouldn't a sum do that?

Andy


On 04 December 2012 at 14:09 jwcolby <jwcolby at colbyconsulting.com> wrote:
> I am doing counts for a set of columns. The values in the column are either 1
> or 0 signifying true
> or false. If I just do a count() as xyz all the columns give a count equal to
> the total number of
> records. I need to do a count of a value of 1.
>
> I discovered that if I change one of the 0 values to a NULL then the record
> with Null does not get
> counted. Thus I could go through the table updating each field which uses this
> method = null where
> '0'.
>
> Obviously this is a lot of work I would like to avoid. However it might be
> faster(?) to do the count?
>
> My preference however is to somehow tell the count() of each column to only
> count values of '1'.
>
> Is this possible in TSQL?
>
> --
> John W. Colby
> Colby Consulting
>
> Reality is what refuses to go away
> when you do not believe in it
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com


More information about the AccessD mailing list