countif in query

  • Thread starter Thread starter count countif
  • Start date Start date
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;
 
Access does not have 'CountIf' as Excel does.
Try this --
SELECT Sum(IIF([Decile] = 9, 1, 0))
FROM TblExtract_VICPOGMfg;
 
Back
Top