I don't have much experience in SQL so I think this is not a dumb question.
I have 2 tables like this.
A .. G are the members of a hierarchy.
Now my requirement is as follows.
I need to filter out the members which has status = 0 from Members table.
But, If the selected set contains children which has a parent with status = 0, Ignore the child and select only the parent.
As an example, in the above case the set with 0 status = {B,C,D,E,F,G} But C,D,E,F has status 0 parents. So my result should be {B,G}
Can I do this just by using SQL and related technologies? (i.e In database layer. I don't want to query into the data structures and then iterate. Can I write a single query for this?)
I will add some more examples if the question is confusing?