title: Oracle SQL: Trying to exclude rows based on a combination of column values
body: <p>I have a table with a list of IDs that I need to exclude rows from. For each row, an ID can have one value in the comment_code column. I need to exclude IDs from my results that have a combination of two specific values and keep IDs that have only one of those two values. Sorry if this isn't clear.</p>
  
  <p>Table example:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Output needed:</p>
  
  <pre><code>ID     SEQUENCE     FUNCTION     COMMENT_CODE
  ---------------------------------------------------------------
  2        1             tree          apple
  </code></pre>
  
  <p>Basically, if an ID has a row with 'apple' as the comment_code and a row with 'orange' as the comment code, I don't want to see that ID in my results. If an ID has a row with 'apple' as a comment code, I want to see them in my results regardless of any other comment_code they may have as long as they don't have the orange comment code.</p>
  
  <p>Any help would be greatly appreciated. I've tried using a combination of exists and not exists clauses as well as listagg to group the comment_code values together for each ID, but I'm not getting the expected result.</p>