I am trying to combine multiple selects in one query to use as little data as possible. I have this sql table (example)
id category status
1 test1 A
2 test2 B
3 test1 A
4 test3 B
5 test1 C
First of all i want to select how many rows there is with the same category.
SELECT category, COUNT(category) FROM test GROUP BY category
Then i would like to count the status in each category. I would do this with this query.
SELECT status, COUNT(status) FROM test WHERE category = 'test1' GROUP BY STATUS
So i want one column with total and then each categorys number of status. Can i somehow combine these? Is that even possible or do i just have to realize that I have to get the data multiple times to have the right result?