I found this string of code on an Oracle forum here: https://forums.oracle.com/forums/thr...readID=2182689
I'm not sure Access has this capability, but perhaps it might help with finding a solution:
Code:
with sample_data as (
select 1 employee_id, 'Active' employment_status, date '1990-01-01' beg_date, date '1991-01-01' end_date from dual union all select 1, 'Leave', date '1991-02-01', date '1993-06-03' from dual union all select 1, 'Active', date '1993-06-04', date '1995-02-01' from dual union all select 1, 'Fired', date '2000-06-01', date '2299-12-31' from dual)select employee_id, employment_status as last_status, end_date as gap_lower_bound, next_date as gap_upper_bound, next_statusfrom ( select t.*, lead(beg_date) over(partition by employee_id order by beg_date) next_date, lead(employment_status) over(partition by employee_id order by beg_date) next_status from sample_data t)where next_date > end_date + 1;