SELECT `u` . `Id` , `CONCAT` ( `CONCAT` ( COALESCE ( `u` . `FirstName` , ? ) , ? ) , COALESCE ( `u` . `LastName` , ? ) ) AS `Name` , `u` . `Email` , `u` . `RoleStr` , `a` . `ComplianceType` , `a` . `SAAssessmentType` , `a` . `IAAssessmentType` , `a` . `EAAssessmentType` , `u` . `OrgEmailId` AS `ParentFAPEmailId` , `u` . `ParentId` FROM `Schedular_Master` AS `s` INNER JOIN `Audit_Schedule` AS `a` ON `s` . `AuditId` = `a` . `Id` INNER JOIN `User_Master` AS `u` ON `a` . `UserId` = `u` . `ParentId` WHERE ( ( TIMESTAMPDIFF ( SQL_TSI_DAY , `s` . `EndDate` , TIMESTAMP (?) ) = ? ) AND NOT ( `a` . `IsDeleted` ) ) AND ( ( ( ( ( `u` . `ParentId` = `a` . `UserId` ) AND NOT ( `a` . `IsDeleted` ) ) AND `a` . `IsActive` ) AND NOT ( `a` . `IsCompleted` ) ) AND ( ( `u` . `RoleStr` = `a` . `ComplianceType` ) OR ( `u` . `RoleStr` IS NULL AND ( `a` . `ComplianceType` IS NULL ) ) ) ) ORDER BY `u` . `Id` 