title: SQL query to do row by row comparison
body: <p>I have table:</p>
  
  <pre><code>        opendt        enddt         Id
          ------------------------------
          2013-01-20    2013-02-20    1
          2013-02-20    2014-02-06    1
          2013-02-28    NULL          1
  </code></pre>
  
  <p>Ideally for record #2 we should have <code>enddt = 2013-02-28</code> but instead it is <code>2014-02-06</code> by mistake. I want to find such records where <code>enddt</code> is not equal to next row <code>opendt</code> for same <code>ID</code>. I know I can try finding this by using <code>temp</code> tables. Is there is a way to do this without <code>temp</code> table? SQL 2012</p>