CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN ci.next_inspection_date <![CDATA[<]]> now() THEN 1 END) * 100.0 / COUNT(*)), 2) END AS expiredRate
CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN ci.next_inspection_date <![CDATA[<=]]> now() THEN 1 END) * 100.0 / COUNT(*)), 2) END AS expiredRate
FROM
"tz_cylinder_inspection" ci
LEFT JOIN tz_cylinder_unit cu on ci.app_id = cu.app_id
<where>
cu.unit_status = '1210'
<iftest="regionCode != null and regionCode != ''">
cu.region_code like concat('%', #{regionCode}, '%')
and cu.region_code like concat('%', #{regionCode}, '%')
</if>
<iftest="appId != null and appId != ''">
cu.app_id = #{appId}
and cu.app_id = #{appId}
</if>
</where>
</select>
...
...
@@ -57,11 +60,12 @@
"tz_cylinder_inspection" ci
LEFT JOIN tz_cylinder_unit cu on ci.app_id = cu.app_id
<where>
cu.unit_status = '1210'
<iftest="regionCode != null and regionCode != ''">
cu.region_code like concat('%', #{regionCode}, '%')
and cu.region_code like concat('%', #{regionCode}, '%')