I want to group by sysCode by max "date" that is get latest documents for each sysCode and then aggregate on employeeId and type field. Below query does not return me