title: difference between two consecutive date in days in sql server
body: <p>Following is the company table, I need to get difference between two consecutive dates in no of days based on companyId and <code>rownum</code></p>
  
  <pre><code>company_id  date    row_num
  101         2017-01-12              1
  101         2017-02-22              2
  118         2017-03-23              1
  119         2017-04-18              1
  123         2017-01-12              1
  123         2017-01-15              2
  123         2017-01-22              3
  501         2017-01-30              1
  501         2017-02-02              2
  </code></pre>
  
  <p>Expected OutPut:   </p>
  
  <pre><code>company_id  date    days
  101         2017-01-12              0
  101         2017-02-22              41
  118         2017-03-23              0
  119         2017-04-18              0
  123         2017-01-12              0
  123         2017-01-15              3
  123         2017-01-22              7
  501         2017-01-30              0
  501         2017-02-02              3
  </code></pre>