SELECT `t` . `OrderRecord` , `t` . `AuditQuestionType` , `t0` . `Id` , `t0` . `Title` , `t0` . `ComplinaceType` FROM ( SELECT `c` . `OrderRecord` , `c` . `AuditQuestionType` FROM `Compliance_Audit` AS `c` WHERE ( `c` . `IsActive` AND NOT ( `c` . `IsDeleted` ) ) AND ( `c` . `ComplinaceType` = ? ) GROUP BY `c` . `AuditQuestionType` , `c` . `OrderRecord` ) AS `t` LEFT JOIN ( SELECT `c0` . `Id` , `c0` . `AuditQuestion` AS `Title` , `c0` . `ComplinaceType` , `c0` . `AuditQuestionType` , `c0` . `OrderRecord` FROM `Compliance_Audit` AS `c0` WHERE ( `c0` . `IsActive` AND NOT ( `c0` . `IsDeleted` ) ) AND ( `c0` . `ComplinaceType` = ? ) ) AS `t0` ON ( ( `t` . `AuditQuestionType` = `t0` . `AuditQuestionType` ) OR ( `t` . `AuditQuestionType` IS NULL AND ( `t0` . `AuditQuestionType` IS NULL ) ) ) AND ( `t` . `OrderRecord` = `t0` . `OrderRecord` ) ORDER BY `t` . `OrderRecord` , `t` . `AuditQuestionType` , `t0` . `Id` 