daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top