select tt.*,(able_amount+incomeAbleTotalAmount- payableTotalAmount) as totalAmount from(
select account_id, dept_id AS deptId , able_amount, IFNULL((select sum(pending_payment) from t_trade_project where trade_status=3 and apply_dept_id =t.dept_id ),0)incomeAbleTotalAmount,IFNULL((select sum(pending_payment) from t_trade_project where trade_status=3 and trade_dept_id =t.dept_id ),0)payableTotalAmount, create_time, update_time, is_del, remark,(SELECT dept.dept_name FROM sys_dept dept WHERE dept.dept_id = deptId)AS dept_name from t_account t
select account_id, dept_id AS deptId , able_amount,transfer_switch, IFNULL((select sum(pending_payment) from t_trade_project where trade_status=3 and apply_dept_id =t.dept_id ),0)incomeAbleTotalAmount,IFNULL((select sum(pending_payment) from t_trade_project where trade_status=3 and trade_dept_id =t.dept_id ),0)payableTotalAmount, create_time, update_time, is_del, remark,(SELECT dept.dept_name FROM sys_dept dept WHERE dept.dept_id = deptId)AS dept_name from t_account t
<where>
<iftest="deptId != null "> and t.dept_id = #{deptId}</if>
<iftest="ableAmount != null "> and t.able_amount = #{ableAmount}</if>
...
...
@@ -47,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"