Question : getting a count of records to not include null or empty records

Here is my query:

select category3, count(distinct category4) as numcategory4, count(distinct item_number) as numitems4 from inventory where price<>'' and not(price is null) and category1='Philatelic Literature' and category2='Handbooks' and category3<>'' and not(category3 is null) group by category3 order by category3

Attached are the results. I am returning the distinct values of category3, the number of category4 that appear within category3 and the number of records matching the category3.

The only problem is... I THINK that the 1's in the numcategory4 are empty or null records (in the category4 column). So those should really be zero.

There are places in the table where there is only one value for category4 (not empty or null). In those cases, a return of 1 would be correct. I basically want a count of the number of distinct category4's (within the current category3) that are not empty or null, in other words. But I have to do this without disturbing the selection of distinct category3 values. Is it possible to modify this query to do what I'm wanting? Thanks!
1:
2:
3:
4:
5:
6:
7:
8:
category3	numcategory4	numitems4
19th Century	1	96
20th Century	1	39
Airmail - U.S. and Worldwide	1	43
Back-of-the-Book	1	14
Colonial and Early Territorial	1	14
Local Posts	1	13
Postal Stationery	1	1

Answer : getting a count of records to not include null or empty records

can you please try this:

count(distinct category4) - max( case when category4 is null then 1 else 0 end) as numcategory4
Random Solutions  
 
programming4us programming4us