title: Trying to find the last time that a value has changed in SQL Server
body: <p>I have a <code>Document</code> table:</p>
  
  <pre><code>| ID|   DOC_ID     | Count|
    1       22           1
    2       22           1
    3       22           2
    4       22           2
    5       22           2
    6       22           3
  </code></pre>
  
  <p>Can I write a SQL query that will only return the latest rows in where a count change occurs? I'm using SQL Server</p>
  
  <p>Desired output :</p>
  
  <pre><code>ID    DOC_ID   Count
  ---------------------
  6       22      3
  </code></pre>