Problem Statement:
I have a data set as follows :
Parent | Child | Country |
---|---|---|
Kim | Jen | A |
Kim | Jen | B |
Tom | Jen | B |
Expected Output : Row 3
Basically query will use the filters Parent and Country and if Country 'A' exists all the rows having same parent-child combinations should be excluded in output.
Tried solutions:
I have tried the below queries:
select Parent, Child, Country
from table joins
where Parent in ('Kim','Tom') and Child in ('Jen') and Country<>'A'
O/P : 2nd and 3rd row
select Parent, Child, Country
from table joins
where Parent in ('Kim','Tom') and Child in ('Jen') and Country<>'A'
EXCEPT
select Parent, Child, Country
from table joins
where Parent in ('Kim','Tom') and Child in ('Jen') and Country='A'
O/P: Incorrect data for larger data sets
Please help me with any other solutions that you have currently.