Access SQL Query Help Using Not Exists -
i have table named sys_event_log following columns:
user_name, event_type, event_message, time_stamp
login , logout events tracked event_type of either "login success" or "logout event"
using sql in access i'm trying return list of distinct users have logged database have not yet logged out based strictly on event log event_types , time_stamps.
the query have come far is:
select distinct a.user_name, a.event_type, a.time_stamp sys_event_log not exists ( select 1 sys_event_log b b.time_stamp > a.time_stamp , a.user_name = b.user_name , a.event_type = "logout event" ) , a.event_type = "login success";
it feels close not returning expected dataset.
select a.user_name , count(*) logins , ( select count( b.time_stamp ) sys_event_log b b.user_name = a.user_name , b.event_type = "logout event" ) logouts , logins - logouts activeconnections sys_event_log a.event_type = "login success" group a.user_name having logins > logouts
Comments
Post a Comment