title: How to increment new column value conditionally
body: <p>I want to generate new column with conditionality incremented value.</p>
  
  <p>Lets say I have demo data like below:</p>
  
  <pre><code>SubjID  dstart  dstop   primarykey
  1       1       4       1
  1       5       15      2
  1       16      25      3
  1       26      35      4
  2       1       4       5
  2       5       15      6
  2       16      25      7
  2       26      35      8
  </code></pre>
  
  <p>Now I want Result like below:</p>
  
  <pre><code>SubjID  dstart  dstop   primarykey  NewCol
  1       1       4       1            1
  1       5       15      2            1
  1       16      25      3            1
  1       26      35      4            1
  2       36      40      5            2
  2       5       15      6            3
  2       16      25      7            3
  2       26      35      8            3
  </code></pre>
  
  <p>So I want to generate New column with below condition:</p>
  
  <p>Only Increment new column rank if any of below condition false</p>
  
  <p>1) Difference between current row's dstart value and previous row's dstop value is not 1</p>
  
  <p>2) Current row's Subject id is different than previous row's subjected</p>
  
  <p>Check NewcCol values in My expected output which need to be generated by your query.</p>