<whentest="Blocks.largeFormat !=null and Blocks.format == null">
join `format` f ON b.housing_estates_id = f.housing_estate_id and f.large_format = #{Blocks.largeFormat} and f.status_cd=1000 and b.status_cd = 1000
join `format` f ON b.housing_estate_id = f.housing_estate_id and f.large_format = #{Blocks.largeFormat} and f.status_cd=1000 and b.status_cd = 1000
</when>
<whentest="Blocks.largeFormat ==null and Blocks.format != null">
join `format` f ON b.housing_estates_id = f.housing_estate_id and f.`format` = #{Blocks.format} and f.status_cd=1000 and b.status_cd = 1000
join `format` f ON b.housing_estate_id = f.housing_estate_id and f.`format` = #{Blocks.format} and f.status_cd=1000 and b.status_cd = 1000
</when>
<whentest="Blocks.largeFormat !=null and Blocks.format != null">
join `format` f ON b.housing_estates_id = f.housing_estate_id and f.`format` = #{Blocks.format} and f.large_format = #{Blocks.largeFormat} and f.status_cd=1000 and b.status_cd = 1000
join `format` f ON b.housing_estate_id = f.housing_estate_id and f.`format` = #{Blocks.format} and f.large_format = #{Blocks.largeFormat} and f.status_cd=1000 and b.status_cd = 1000
</when>
<otherwise>
where b.status_cd = 1000
</otherwise>
</choose>
and b.housing_estates_id = #{Blocks.housingEstatesId}
and b.housing_estate_id = #{Blocks.housingEstateId}