Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID SEQUENCE FUNCTION COMMENT_CODE
- ---------------------------------------------------------------
- 1 1 tree apple
- 1 2 bush orange
- 2 1 tree apple
- 2 2 tree banana
- 3 1 bush strawberry
- ID SEQUENCE FUNCTION COMMENT_CODE
- ---------------------------------------------------------------
- 2 1 tree apple
- select *
- from table t left outer join
- (select id
- from table t
- group by t.id
- having sum(case when comment = 'apple' then 1 else 0 end) > 0 and
- sum(case when comment = 'orange' then 1 else 0 end) > 0
- ) toexclude
- on t.id = toexclude.id
- where toexclude.id is null;
- select *
- from yourtable
- where sequence = 1
- and whatever
Add Comment
Please, Sign In to add comment