I have a mysql table with 3 columns:
- id [int]
- name [varchar]
- time [timestamp CURRENT_TIMESTAMP]
- flag [boolean]
I am using a query like this to group the results by day:
SELECT COUNT(DISTINCT name), DATE(time) as day FROM `table` GROUP BY day
That works fine, but what I really want to get COUNT(DISTINCT name) WHERE FLAG = 0
and COUNT(DISTINCT name) WHERE FLAG = 1
in the same query and group them by day.
How can I do that?