Last Login Report - All Users

Last Login Report - All Users

SELECT AaaUser.FIRST_NAME "Users",
MAX(AaaLogin.NAME) "LoginName",
MAX(AaaContactInfo.EMAILID) "Email",
MAX(AaaAccSession.USER_HOST) "IP Address",
longtodate(MAX(AaaAccSession.OPENTIME)) "Logged In Time" ,
longtodate(MAX(AaaAccSession.CLOSETIME)) "Logged Out Time"  FROM AaaUser 
INNER JOIN SDUser ON AaaUser.USER_ID=SDUser.USERID
Left  JOIN HelpDeskCrew ON SDUser.USERID=HelpDeskCrew.TECHNICIANID
LEFT JOIN AaaLogin ON AaaUser.USER_ID=AaaLogin.USER_ID 
INNER JOIN AaaAccount ON AaaAccount.login_id=AaaLogin.LOGIN_ID
INNER JOIN AaaAccSession ON AaaAccount.ACCOUNT_ID = AaaAccSession.ACCOUNT_ID
LEFT JOIN AaaUserContactInfo ON AaaUser.USER_ID=AaaUserContactInfo.USER_ID
LEFT JOIN AaaContactInfo ON AaaUserContactInfo.CONTACTINFO_ID=AaaContactInfo.CONTACTINFO_ID  WHERE  SDUser.STATUS = 'ACTIVE' 
GROUP BY AaaUser.FIRST_NAME