On Thu, Mar 27, 2008 at 10:16 AM, Olaf Stein <
[EMAIL PROTECTED]> wrote:

> I have a table with 40 columns. If for a record a value is not available
> the
> column is set to NULL. Is there a quick way of finding out how many
> records
> have a value (NOT NULL) for 90% (or lets say 35 columns) of the columns.
>

Quick and dirty I would write a query that would compute a score for each
row based on the number of rows:
if(col1 IS NULL,0,1)+if(col2 IS NULL,0,1)

and based on that perform a test to see if the row is NULL'enough (or
whatever):
if(if(col1 IS NULL,0,1)+if(col2 IS NULL,0,1) +if(col2 IS NULL,0,1) +if(col2
IS NULL,0,1)>3, 1,0)
so that will return 1 if 3 out of 4 are NULL, and 0 otherwise.

and you could throw all of that inside of a sum() and get the number of rows
that fit your pattern.

-- 
Rob Wultsch

Reply via email to