Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • Thank you for the answer, while I ended up not using this as my final solution it did make me see where I was going wrong. Instead of the OUTER APPLY that you suggested I used a nested select like so: select *, (select top 1 historyon from #webhist u2 where u2.historyon > u1.historyon and u1.unit = u2.unit) from #webhist u1; Commented Aug 29, 2014 at 7:52
  • Even simpler :) Glad to help. Commented Aug 29, 2014 at 11:07