not returning 0 if value is NULL
You are wanting GROUP BY and the COUNT aggregate to return a row with a zero value when there are otherwise no rows to return - GROUPing does not work like that. It combines what rows would have been returned if GROUP BY was not present, so no rows in that case.
You could add a second SELECT, combined with UNION ALL, that returns one row containing inyear, incode, 0 if there are zero matching rows (counted by sub-select). If there are rows this part returns nothing, if there are no matches it returns a row indicating that. Note that this may be quite inefficient.