Write a complex SQL query utilizing window functions and multi-table joins to identify users who logged in from two different geographical locations within a 10-minute window.
Use consecutive login records for each user. Include only transitions with two known, different locations and a time difference of no more than 10 minutes.
Output
- One row per qualifying login transition.
- Return
user_id, user_name, previous_login_at, previous_location, current_login_at, current_location, and minutes_between.
- Order by
user_id, then current_login_at, then current_login_id.