Guest User

Untitled

a guest
Dec 7th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. ID SEQUENCE FUNCTION COMMENT_CODE
  2. ---------------------------------------------------------------
  3. 1 1 tree apple
  4. 1 2 bush orange
  5. 2 1 tree apple
  6. 2 2 tree banana
  7. 3 1 bush strawberry
  8.  
  9. ID SEQUENCE FUNCTION COMMENT_CODE
  10. ---------------------------------------------------------------
  11. 2 1 tree apple
  12.  
  13. select *
  14. from table t left outer join
  15. (select id
  16. from table t
  17. group by t.id
  18. having sum(case when comment = 'apple' then 1 else 0 end) > 0 and
  19. sum(case when comment = 'orange' then 1 else 0 end) > 0
  20. ) toexclude
  21. on t.id = toexclude.id
  22. where toexclude.id is null;
  23.  
  24. select *
  25. from yourtable
  26. where sequence = 1
  27. and whatever
Add Comment
Please, Sign In to add comment