@David M. Rosenblum
Thank you for the feedback and using Microsoft Q&A platform.
You are correct that the JOIN condition in the example you provided may seem redundant. Since we are already grouping the events into 10-minute windows and selecting the last event in each window, the condition ON DATEDIFF(minute, Input.Time, LastInWindow.LastEventTime) BETWEEN 0 AND 10 might not be necessary.
However, it is possible that this condition was included as an extra precaution to ensure that only events within the correct time window are selected. In any case, removing this condition should not affect the final result.
Hope this helps. Do let us know if you have any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.