I am trying to obtain the following result:
Imagine I have an object table in the following format
Name | Object id | Status |
---|---|---|
A | A. | . On |
A | B. | . Off |
A | C. | . Other |
B | D. | . On |
B | E. | . Other |
B | F. | . Other |
And I want the following result
Name. | count of objects with status On or Off |
---|---|
A | 2 |
B | 1 |
In words, my goal is, for each name, to count the number of objects by status, which I can easily do with a group by ‘Status’ query, but to sum two of the possible statuses.
Thank you
2
Answers
Using
sum
:See fiddle
You can use
conditional aggregation
.