I have the following table with columns:
outbox
outbox-> id (pri/index)
outbox-> email
outbox-> mobile_no (char 12)
outbox-> category (members/leaders)
outbox-> channel (A/B/C)
outbox-> send_status (pending/sent/declined)
I need to display the counts of the above data to answer the questions:
1) How many outbox items belong to each category
2) How many outbox items belong to each channel
3) How many outbox items are in each send_status
So instead of doing multiple SELECT count (id) WHERE clauses I figured GROUP BY would be better. But I don't see a way to do it in 1 SQL statement .. so instead i have the following:
I have the following:
SELECT category , count(id) AS total_msgs FROM outbox GROUP BY (category );
SELECT channel , count(id) AS total_msgs FROM outbox GROUP BY (channel);
SELECT send_status, count(id) AS total_msgs FROM outbox GROUP BY (send_status);
I just wanted to run this by you guys and see what you thought of it.
PS
I do have a stats table that is regularly updated so no need to suggest that.