I have two tables to track user activity:

I need to write a SQL query to get data in below format
:
UserId|UserRole|LoginTime|LogOutTime
Note : LoginTime/LogOutTime is Activity_Time_Stamp in ActivityAuditTrail table. I am not able to figure out a logic for this.
I’m being on the safe side and assuming that sessions are not unique to a user, but if they are you may be able to leave out the user_id from the WHERE entirely.