My SQL
SELECT nce.id, nce.send, count( * ) AS total
FROM `newsletter_email` nce
WHERE 1
GROUP BY nce.id, nce.send
Produces the result:
id send total
4 0 6
4 1 1
5 0 2
6 1 7
7 1 4
8 0 2
8 1 4
9 1 1
But I want the result to be:
id send no_send total
4 6 1 7
5 0 2 2
6 7 0 7
7 4 0 4
8 4 2 6
9 1 0 1
I have tried several ways but it did not give the expected result. Can you help?
Assuming Send has value of 1 for send and 0 for no_send, you can simply sum values of send:
However, general pattern would be: