I have 2 tables a table of PARENT ACCOUNTS (holds PARENT ID and CHILD ID) a table of CHILD ACCOUNTS (Holds CHILD ID and ATTRIBUTE)
1 PARENT can have many CHILDREN
Each Child has one or more attributes, and each child must have the same as the other in the parent group
so if Parent 1 has Child1, Child2, Child3
Child1, Child2, Child3 MUST have the same attribute - say they are BLUE
If Child3 is missing this attribute (doesn't exist) then I need to show All the Child accounts and highlight which one is the missing one.
select Child, Parent,Attribute
from
[dbo].[AttributeTable] as AttReq
LEFT OUTER JOIN
[dbo].[ChildDetails] ChildDetails
ON AttReq.Child = ChildDetails.Child
where Parent = 'Parent1'
| CHILD ACOUNT | PARENT ACCOUNT | ATTRIBUTE |
|---|---|---|
| Child1 | Parent1 | Attribute 1 |
| Child1 | Parent1 | Attribute 2 |
| Child1 | Parent1 | Attribute 3 |
| Child2 | Parent1 | Attribute 1 |
| Child2 | Parent1 | Attribute 4 |
| Child2 | Parent1 | Attribute 2 |
| Child2 | Parent1 | Attribute 3 |
| Child3 | Parent1 | Attribute 1 |
| Child3 | Parent1 | Attribute 2 |
| Child3 | Parent1 | Attribute 3 |
So this one, only Child 2 has attribute 4.
I want to list all the Child accounts that are missing 4 - and which one HAS 4. I don't need to show which ones they all have.
| CHILD ACOUNT | PARENT ACCOUNT | ATTRIBUTE |
|---|---|---|
| Child1 | Parent1 | Missing Attribute 4 |
| Child2 | Parent1 | Missing Attribute 4 |
| Child3 | Parent1 | Has Attribute 4 |