Пока мы ждем образцы данных, я составил свои собственные (строки №1-15, поэтому запрос, который может помочь, начинается со строки №16). Посмотрим, поможет ли.
SQL> with test (fisc_yr, id) as
2 (select 2017, 100 from dual union all
3 select 2017, 101 from dual union all
4 select 2017, 102 from dual union all -- 2017: result = 3
5 --
6 select 2018, 100 from dual union all -- 100 exists in year 2017
7 select 2018, 200 from dual union all
8 select 2018, 201 from dual union all -- 2018: result = 2
9 --
10 select 2019, 300 from dual union all -- 300 nor 301 exist in year 2018
11 select 2019, 301 from dual union all -- 2019: result = 2
12 --
13 select 2020, 400 from dual -- 2020: result = 1
14 )
15 --
16 select a.fisc_yr,
17 count(distinct a.id) count_ids
18 from test a
19 where not exists (select null
20 from test b
21 where b.fisc_yr = a.fisc_yr - 1
22 and b.id = a.id
23 )
24 group by a.fisc_yr
25 order by a.fisc_yr;
FISC_YR COUNT_IDS
---------- ----------
2017 3
2018 2
2019 2
2020 1
SQL>