Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- eid | fid
- ----+----
- 1 | A
- 1 | B
- 1 | C
- 2 | B
- 2 | C
- 3 | A
- 3 | C
- 4 | A
- 4 | B
- 5 | B
- select t1.eid
- from t t1
- where t1.fid = 'B'
- and not exists
- (select 1
- from t t2
- where t2.eid = t1.eid
- and t2.fid = 'A')
- Select eid from t where fid = 'B'
- EXCEPT
- select eid from t where fid = 'A'
- SELECT DISTINCT t1.eid
- FROM table1 AS t1
- LEFT JOIN table1 AS t2 ON (t1.eid = t2.eid AND t2.fid = 'A')
- WHERE t2.eid IS NULL
- AND t1.fid = 'B';
- SELECT DISTINCT t1.eid
- FROM table1 AS t1
- LEFT JOIN table1 AS t2 ON (t1.eid = t2.eid AND t2.fid = 'A')
- WHERE t2.eid IS NULL
- AND t1.fid = 'B';
- select eid
- from t
- where fid = 'A'
- minus
- select eid
- from t
- where fid = 'B'
Add Comment
Please, Sign In to add comment