I want to avoid selecting the cases where there is a blank child, but only where a parent-child relationship already exists. So in this example, A-D would stay but the empty rows with A should get removed. As C doesn't have any children in any row, it will remain.
Input:
parent child
A D
A
A
B E
B F
C
Desired Output:
parent child
A D
B E
B F
C
What I've tried:
SELECT parent, child
FROM my_table
WHERE child NOT NULL
EXCEPT
SELECT parent, child
FROM my_table
-- condition to check existing relationships if they exist