Link to home
Start Free TrialLog in
Avatar of GIStewart
GIStewart

asked on

Query to exclude records with null values across multiple fields

I am sure this is easy for everyone but me!

I have a table with 4 fields, and each record can have between zero and 4 values across these fields.  I am looking for a query that includes any record with at least 1 value across these fields, and excludes any with none.  For example, in the attached sample file, records 4, 7 and 9 would not be displayed in the query, but the rest would be.
EE-sample-Apr29.mdb
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Select (iff(isnull(column1),1,0)) as col1,(repeat) where col1+col2+col3+col4 >= 1

Or select * where (col1 is not null or col2 is not null or col3 is not null or col 4 is not null)
Avatar of GIStewart
GIStewart

ASKER

I renamed my columns col1, col2, col3, col4, and then used the following code in a query:

SELECT * from Table1 where (Col1 is not null or Col2 is not null or Col3 is not null or Col 4 is not null);

but i get a syntax error (missing operator) message.
ASKER CERTIFIED SOLUTION
Avatar of ssisworo
ssisworo
Flag of Indonesia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.