Question: Imagine this db structure:

```
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`correct` tinyint(1) NOT NULL DEFAULT '0'

```

I want to get the count of all entries with `correct = 1`, *and* the count of all entries with `correct = 0`, in *one* query.

How do I do this?

Answer: 
```
select count(case when correct = 0 then 1 end) as ZeroCount,
    count(case when correct = 1 then 1 end) as OneCount
from MyTable

```
If you want the counts in one row:

```
SELECT SUM(correct=0) as number_of_zeros,SUM(correct=1) as number_of_ones
FROM table;

```

If you want them in multiple rows:

```
SELECT correct,COUNT(*)
FROM table
GROUP BY correct;

```