title: Alternatives to LAG() in sql server 2008
body: <p>I asked this question: </p>
  
  <p><a href="https://stackoverflow.com/q/39503683/4294028">create partition based on the difference between subsequent row indices in sql server 2012</a></p>
  
  <p>I am just wondering how this could be done in an older version of sql server, say sql 2008 in which LAG is not a recognised function. Is there anyway to implement the lag function in older versions of SQL??</p>
  
  <p><strong>EDIT</strong>: perhaps I should have been more explicit, in the solution to the referred question, the lag function is used multiple times, is there a more efficient way than using multiple CTEs to get the same result?</p>