SELECT YearMonth,Supplier, Sum(IQC_Check.FailQty) AS FailQty
FROM IQC_Check
GROUP BY YearMonth,Supplier;
Query2:
SELECT YearMonth,Supplier,FailQty,DCount("[FailQty]","Query1","[YearMonth]='" & [YearMonth] & "' and [FailQty]<=" & [FailQty]) AS [No]
FROM Query1
ORDER BY Query1.YearMonth, DCount("[FailQty]","Query1","[YearMonth]='" & [YearMonth] & "' and [FailQty]<=" & [FailQty]);