• Be careful about using DailyMileageID+1. You could have holes if it's an identity column (when you delete rows, for example), and also is the sort order definitely correct?

    Look in your data for another way of identifying the next / previous row.

    Regards,

    David.