Search code examples
sqlms-access-2010having-clause

Keeps counting all the text values instead of me providing a criteria in SQL


I have very simple query, to count the number of Cause Cancel from the Decision column. It keeps counting all the text values in the column and not just cause cancel.

SELECT Marketics.Case, Count(Marketics.Decision) AS CountOfDecision
FROM Marketics
GROUP BY Marketics.Case
HAVING Count(Marketics.Decision="Cause Cancel");

Solution

  • I think you want a WHERE clause not a HAVING clause:

    SELECT Marketics.Case, Count(Marketics.Decision) AS CountOfDecision
    FROM Marketics
    WHERE Marketics.Decision = "Cause Cancel";
    GROUP BY Marketics.Case