Great article.
Lars Nordin
31

That is a great solution! I have only used that clause once and totally forgot about it. You are correct. You could cut out the two temp tables and just have one query that gets both the current value and the next leading value for the date.

The one caveat here is if you need to compare multiple columns. Not just one as in my example. Then it would get a little messy because you would need to make a lead statement for each field.

Thank you for your input!