<select id="rptRimProjectDetailQuery" resultMap="BaseResultMap"> SELECT V.*, (case when V.REMAIN_PRINCIPAL > 0 then (V.REMAIN_PRINCIPAL - nvl( (SELECT SUM(CCC.DUE_AMOUNT) FROM CON_CONTRACT_CASHFLOW CCC WHERE CCC.CONTRACT_ID = V.CONTRACT_ID AND CCC.CF_ITEM = 5) ,0)) else0 end) as PROJECT_EXPOSURE FROM (SELECT --项目编号 CC.PROJECT_CONTRACT_NUMBER PROJECT_NUMBER, -------------------------省略部分代码------------------------- -- 项目核销申请日期 (SELECT CCT.TERMINATION_DATE FROM CON_CONTRACT_TERMINATION CCT WHERE CCT.CONTRACT_ID = CC.CONTRACT_ID) TERMINATION_DATE, CC.BEFORE_RENT_FLAG FROM CON_CONTRACT CC LEFT JOIN PRJ_PROJECT PP ON CC.PROJECT_ID = PP.PROJECT_ID WHERE cc.contract_status IN('INCEPT', 'TERMINATE', 'ET') OR(CC.contract_status = 'SIGN' AND cc.before_rent_flag = 'Y') ) V ----------------下面写查询条件---------------------- <where> <if test="projectNumber !=null and projectNumber !=''"> and v.project_number like concat(concat('%',#{projectNumber}),'%') </if> <if test="businessType !=null and businessType.size() !=0"> and v.business_type in <foreach item="item" index="index" collection="businessType" open="(" separator="," close=")"> #{item} </foreach> </if> </where> </select>