问题
I am in the middle of making a Client a Access Database and am stuck on how to work around what im doing.
i have a table with somthing like i have a table called Observations with somithing like this
Error Identified | Error Cat | ... | So on
No | | |
Yes | Dave3 | |
Yes | Dave | |
Yes | Dave3 | |
Yes | Dave5 | |
Yes | Dave | |
Yes | Dave6 | |
Yes | Dave6 | |
Yes | Dave | |
I want to count the number of occurrences that each [Error Cat] where [Error Identified] is yes
so it would bb
Error Cat | Count |
Dave | 3 |
Dave3 | 2 |
Dave5 | 1 |
Dave6 | 2 |
What is the Access SQL for this to happen
I tried so hard but it just wont run the SQL Please help.
回答1:
SELECT ErrorCat, COUNT(*) totalCount
FROM tableName
WHERE ErrorIdentified = 'YES'
GROUP BY ErrorCat
来源:https://stackoverflow.com/questions/13504991/accesssql-count-distinct-fields-and-group-by-field-name