• OK, fair enough.

    The OUTPUT clause goes before the WHERE clause. Are you not getting a syntax error?

    Some sample data would be very helpful here. If the StartTime to EndTime period on any of your rows overlaps with that of any other row, then you can't guarantee a one-to-one mapping.

    John