Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null values in query

Status
Not open for further replies.

weezles

Technical User
Jul 18, 2003
81
GB
Hi

I have the following query:

SELECT Ethnicity, Count(Ethnicity) as Total
FROM qryEth
GROUP BY Ethnicity;

How can i deal with null values? The combo box contains 15 items and i only want to show those that are not null. The output from this query =

0
White 10
Mixed 2

I want to get rid of the blank field and the 0 for producing a tabular report. I have looked at the NZ function and IIF but the results could show different ethnic origins each time.

Can anyone help?

Thanks

Lou
 
change your sql to

Code:
SELECT qryEth.Ethnicity, Count(qryEth.Ethnicity) AS Total
FROM qryEth
GROUP BY qryEth.Ethnicity
HAVING (((qryEth.Ethnicity) Is Not Null));

that should do the trick, if not let me know
 
And as the test doesn't need aggregate function one more efficient way:
SELECT Ethnicity, Count(Ethnicity) as Total
FROM qryEth
WHERE Ethnicity Is Not Null
GROUP BY Ethnicity

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top