I have a collection of parent items and each has an indeterminate set of child items. Each child item as an attribute that is X
or NULL
. (Apologies for the odd Boolean structure, but that's what I have to work with.)
Parent Child Attribute
------ ----- ---------
A 1 X
A 2 X
A 3 NULL
B 1 X
B 2 NULL
B 3 NULL
C 1 X
C 2 X
D 1 NULL
E 1 NULL
E 2 NULL
I want to identify parent items as True or False based on the child items. One NULL
value will result in a False return for that parent item. Here are the desired results:
A False
B False
C True
D False
E False
The ideal solution would even handle a parent that has no child records (result is False).
I can do this using temporary tables. That solution is fairly long and I don't think presenting it would add any value to this post.
How can I do this with an SQL query using no temporary tables?
I would present "things I've tried" but I don't know enough how to even start.