countif in query

C

count countif

I would like to know how to use the countif statement in a query. I have run
one query which makes a table. I am now running smaller queries against this
table to count the number of records if the field named Decile = 9. Here is
the base query in SQL.

SELECT TblExtract_VICPOGMfg.HH, TblExtract_VICPOGMfg.Mfg_Brand,
Sum(TblExtract_VICPOGMfg.Units) AS SumOfUnits,
Sum(TblExtract_VICPOGMfg.Units) AS [Total Of Units] INTO
UnitSumByHouseholdDecile080910
FROM TblExtract_VICPOGMfg
GROUP BY TblExtract_VICPOGMfg.HH, TblExtract_VICPOGMfg.Mfg_Brand,
TblExtract_VICPOGMfg.Decile;
 
K

KARL DEWEY

Access does not have 'CountIf' as Excel does.
Try this --
SELECT Sum(IIF([Decile] = 9, 1, 0))
FROM TblExtract_VICPOGMfg;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top