So the total for 102378 is different because I was screening from a November 1, 2017 rather than January.
The previous database owner was trying to reference other tables that have a massive amount of duplicate/unneeded data in them but their attempt to at least reduce that info for a manual filtering process is below.
Code:
SELECT tbl_Calendar.FY, tbl_Calendar.ADate, tbl_KM_PERS_TRACK.SSN, tbl_SSN_CTGY_ABCDF_Days_In_FY16.SailorID, tbl_KM_PERS_TRACK.EVENT_AUIC, tbl_KM_PERS_TRACK.PERSTEMP_CAT_CD, tbl_KM_PERS_TRACK.TRAK_STRT_DT, tbl_KM_PERS_TRACK.ACTL_PROJ_STOP_DT, GetDaysOverlap([TRAK_STRT_DT],[ACTL_PROJ_STOP_DT]-1,[ADATE]-365,[ADate]) AS Days
FROM tbl_Calendar, tbl_KM_PERS_TRACK INNER JOIN tbl_SSN_CTGY_ABCDF_Days_In_FY16 ON tbl_KM_PERS_TRACK.SSN = tbl_SSN_CTGY_ABCDF_Days_In_FY16.SSN
WHERE (((tbl_Calendar.ADate) Between [Start Dt] And [Stop Dt]) AND ((tbl_KM_PERS_TRACK.PERSTEMP_CAT_CD) In ("A","B","C","D","F")) AND ((tbl_KM_PERS_TRACK.TRAK_STRT_DT)<=[ADate]) AND ((tbl_KM_PERS_TRACK.ACTL_PROJ_STOP_DT)>[ADate]-365) AND ((GetDaysOverlap([TRAK_STRT_DT],[ACTL_PROJ_STOP_DT]-1,[ADATE]-365,[ADate]))>0));
As far as my latest attempt goes, I utilized a simpler table that is continually updated and still has all the data needed. I made some minor changes to fit the current request (like calendar year vice fiscal). These return results but it takes an eternity to run (more than a few hours) and the data is clearly skewed as some totals exceed 1000 days. At this point in my design, I haven't tried to filter by more than 220 yet.
Code:
SELECT DISTINCTROW tbl_Calendar.CY, tblTempo.ID, tblTempo.[Category Code], Count(tblTempo.Consecutive_Days) AS CountOfConsecutive_Days
FROM tbl_Calendar, tblTempo
WHERE (((tbl_Calendar.ADate) Between [Start Dt] And [Stop Dt]) AND ((tblTempo.Consecutive_Begin_Date)<=[ADate]) AND ((tblTempo.Consecutive_End_Date)>[ADate]-365) AND ((GetDaysOverlap([Consecutive_Begin_Date],[Consecutive_End_Date]-1,[ADATE]-365,[ADate]))>0))
GROUP BY tbl_Calendar.CY, tblTempo.ID, tblTempo.[Category Code]
HAVING (((tblTempo.[Category Code]) In ("A","B","C","D","F")));