select
count(distinct t.applyform_id) total_records
from sup_po_apply_form t
inner join sup_po_sw_info i on t.CONTRACT_NO = i.CONTRACT_NO and t.pp_product = i.pp_product
inner join sup_sc_family_info s on i.pp_product = s.pp_product
<dynamic>
<isNotEmpty property="APPLYFORM_STATUS" prepend="AND">
t.APPLYFORM_STATUS in ($APPLYFORM_STATUS$)
</isNotEmpty>
<isNotEmpty property="APPLY_TIME" prepend="AND">
TO_CHAR(t.APPLY_TIME, 'yyyy-mm-dd') = #APPLY_TIME#
</isNotEmpty>
<isNotEmpty property="CONTRACT_NO" prepend="AND">
t.CONTRACT_NO like '%'||#CONTRACT_NO#||'%'
</isNotEmpty>
<isNotEmpty property="PO_NO" prepend="AND">
t.PO_NO like '%'||#PO_NO#||'%'
</isNotEmpty>
<isNotEmpty property="APPLYFORM_ID" prepend="AND">
t.APPLYFORM_ID like '%'||#APPLYFORM_ID#||'%'
</isNotEmpty>
<isNotEmpty property="APPLICANT_ACCOUNT" prepend="AND">
t.APPLICANT_ACCOUNT=#APPLICANT_ACCOUNT#
</isNotEmpty>
<isNotEmpty property="AUDITER" prepend="AND">
t.AUDITER=#AUDITER#
</isNotEmpty>
<isNotEmpty property="CREATOR" prepend="AND">
t.CREATOR=#CREATOR#
</isNotEmpty>
<isNotEmpty property="productline_id" prepend="AND">
i.productline_id = #productline_id#
</isNotEmpty>
<isNotEmpty property="product_family" prepend="AND">
s.product_family = #product_family#
</isNotEmpty>
<isNotEmpty property="product" prepend="AND">
s.product = #product#
</isNotEmpty>
</dynamic>