I have a following table:
id | R_ID | is_assigned
-----------------
1 | X1 | 1
2 | X1 | 0
3 | X1 | 0
4 | X1 | 0
I want to get two different COUNT() values: one for all rows that belong to group X1. And next for rows that belong to group X1 and are not assigned, i.e. is_assigned value 0.
Output:
R_ID | Total Records | Remaining
----------------------------------
X1 | 4 | 3
This is as far as I could get:
SELECT t1.r_id, COUNT(t1.*) as total_records
FROM tasks t1
GROUP BY r_id
How do I get another count?