Help with a script

The problem is where you are trying to use I.PatientIdentityID - the outer query should be race_row.PatientIdentityID - the first derived table should be Race_Num_flg.PatientIdentityID.

If you look down the 1st section of the code, there is:
AND CASE WHEN Month(PAT.DeathDTS) > 9 THEN YEAR(PAT.DeathDTS) + 1 ELSE YEAR(PAT.DeathDTS) END >= @FY

Okay - you still don't need to filter based on the 'FY'. Calculate the start date as: datefromparts(2015, 10, 1) - which is the start of FY 2016 and just get any date of death greater than that date.

Calculate the FY as you are now...

Thanks Jeff. That was extremely helpful