title: Deleting all rows from table that share the same ID
body: <p>I have the following table:</p>
  
  <pre><code>Name     |   ID  |  date    |
  Login    |   1   | somedate |
  Command  |   1   | somedate |
  Command  |   1   | somedate |
  Login    |   2   | somedate |
  Command  |   1   | somedate |
  Command  |   2   | somedate |
  Logout   |   1   | somedate |
  Command  |   2   | somedate |
  </code></pre>
  
  <p>I want to delete from the table everything between a login and a logout that share the same ID, but keep everything else there. The somedate fields are datetime. There could be more logins/logouts in the table and there will be Logins that don't have a corresponding logout. I want that to remain there because the logout will appear eventually.</p>
  
  <p>I was thinking of using a cursor. Which would be the best approach for performance too? The final table could have a few millions of rows.</p>
  
  <p>After the delete the table should look like this:</p>
  
  <pre><code>Name    |  ID  |  
  Login   |  2   |
  Command |  2   |
  Command |  2   |
  </code></pre>
  
  <p>Edit: Delete everything between a Login and a Logout, including the rows with Login/Logout.</p>