Hello reader,
Currently These are my groups from a _single_ table (column left = CustomerID, column right = Status)
Group A contains:
A_Cust_12 1
A_Cust_13 6
A_Cust_14 3
A_Cust_15 1
Group B contains:
B_Cust_75 3
B_Cust_76 5
B_Cust_77 3
B_Cust_78 1
Group Special contains:
A_Cust_12 2
So far the columns from a table.
I grouped them as you can see. I want to know the distinctcount of CustomerID in each group, having state 1.
But...
Look at
A_Cust_12. This CustomerID is also to be found within group +Special+. And in group +Special+ it has Status 2. therefore, the
A_Cust 12 in
group A is not to be counted.
State 1 means "paid". But when the customer is in
Group Special with State 2 (and 2 only) then something went wrong with the payment. Anyone in Group A or B can only have the same CustomerID in group Special only. A can not occur within group B for example. So if it's in group "Special" with a certain state, then don't count it.
So the real count of CustomerID's in group A = 3. Number 12 doesn't count.
How do I do this? I've worked on this for a full day but I can't get it for the life of me.
Please do mind that more groups can (and will) exist, but there is only one group "Special".