I have a table that contains ids with different deltas as separate rows. So an id can have a 0 delta or delta 1 or both deltas 0 and 1. I am trying to find those ids that have delta 0 but not delta 1.
Those ids must be inside a list of ids that are returned from another query. I can separately retrieve those two sets, but how do I make the cross-reference within the same query?
example:
dataset
id|delta
1 | 0
1 | 1
2 | 0
3 | 0
4 | 1
5 | 1
expected result:
ids 4,5
query
select m.id from table m where m.delta=0 and m.id in (LIST OF IDS FROM ANOTHER QUERY)
and
select n.id from table n where n.delta=1 and n.id in (LIST OF IDS FROM ANOTHER QUERY)