I need to count a the amount of unread messages per type of a messages table.
Table: Messages
Fields:
Id Message Type Unread
1 xxxxx 0 0
2 xxxxx 1 0
3 xxxxx 1 0
4 xxxxx 1 1
5 xxxxx 2 0
6 xxxxx 3 0
7 xxxxx 3 1
So, I need a result like this:
For type 0 there is 1 unread message, and a total of 1 message.
For type 1 there are 2 unread messages, and a total of 3 messages.
For type 2 there is 1 unread message, and a total of 1 message.
For type 3 there is 1 unread message, and a total of 2 messages.
So far, I was able to count how many messages I've per type:
SELECT
`message_type`,
COUNT(`message_type`) AS message_type_count
FROM
Messages
GROUP BY `message_type`
But, I also need the amount of unread messages per type. How can I do that?
Thanks for your help!