title: SQL select all items with the same column values
body: <p>So here is the output of my current query:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Col1</th>
  <th>Col2</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>871</td>
  <td>1</td>
  <td>1</td>
  </tr>
  <tr>
  <td>646</td>
  <td>1</td>
  <td>Null</td>
  </tr>
  <tr>
  <td>1223</td>
  <td>8</td>
  <td>1</td>
  </tr>
  <tr>
  <td>1223</td>
  <td>8</td>
  <td>2</td>
  </tr>
  <tr>
  <td>1223</td>
  <td>8</td>
  <td>3</td>
  </tr>
  <tr>
  <td>1224</td>
  <td>1</td>
  <td>1</td>
  </tr>
  <tr>
  <td>1224</td>
  <td>1</td>
  <td>2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>What I'd like to do is only keep the rows which satisfy the following:</p>
  <ul>
  <li>Col2 is Null; or</li>
  <li>ID+Col1 == Col2 for one of the rows with the same ID, e.g., the bottom two rows are not included because the second from the bottom Col1==Col2 and the bottommost is not included because the ID and Col1 match the second from the bottom in which Col1==Col2.</li>
  </ul>
  <p>For this table, the only rows which should remain are the ones with IDs 646 and 1223.</p>
  <p>I tried the following <code>where</code> clause, however it's improperly retaining the bottommost row: <code>(Col2 is null and Col1 is not null) or (Col1 &lt;&gt; Col2)</code>. Any help appreciated!!</p>