title: Remove rows whose sum is equal to 0
body: <p>For example I have a simple table with values:</p>
  
  <pre><code>|Code|Value|
  |x1  |5    |
  |x2  |-5   |
  |x3  |-5   |
  |x4  |5    |
  |x5  |5    |
  </code></pre>
  
  <p>I need to remove rows whose sum is equal to 0.
  I.e. for this example I'll want to remove rows with codes x1 and x2, x3 and x4 OR x1 and x2, x3 and x5 - it doesn't matter in my case.</p>
  
  <p>It sounds like simple task, but I can't do it.<br>
  I can't even understand how to select the items I want to delete.</p>
  
  <p>I tried to join table on itself like this:</p>
  
  <pre><code>SELECT 
      t1.Code AS Code1,
      t2.Code AS Code2
  FROM TableX AS t1
  JOIN TableX As t2
  ON t1.Code &lt;&gt; t2.Code
      AND t1.Value + t2.Value = 0
  ORDER BY t1.Code
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>|Code1|Code2
  |x1   |x2
  |x1   |x3
  |x2   |x1
  |x2   |x4
  |x2   |x5
  |x3   |x1
  |x3   |x4
  |x3   |x5
  |x4   |x2
  |x4   |x3
  |x5   |x2
  |x5   |x3
  </code></pre>
  
  <p>But I don't understand what should I do next. </p>
  
  <p>I'm not lazy - I tried different variants - with GROUP BY and MIN, with ROW_NUMBER() but unfortunately I can't understand how can I select rows to delete and leave others?</p>