mysql伪列 映射语句_多表联合查询 mybatis注解方式 sql虚拟字段 映射封装 动态SQL语句的拼接...

@Select({"

"SELECT t.ID,t.projectName,b.borrowUnitName as borrowUnitName,l.loanUnitName as loanUnitName,t.startData,t.endData,t.loanMoney,SUM(d.drawed) as drawed,t.repayed,t.toRepayed,t.interest_repayed as interest_repayed,t.repayWay,t.contractRepayTime,t.actualRepayTime,t.financingMode,t.contractStatus,t.examineStatus,t.contractWritter\n" +

"FROM (select c.ID,c.projectName,c.borrow_id,c.loan_id,c.startData,c.endData,c.loanMoney,sum(r.repayed) as repayed,SUM(r.repayTotal)-SUM(r.repayed) as toRepayed,SUM(r.interest_repayed) as interest_repayed,r.repayWay,r.contractRepayTime,r.actualRepayTime,c.financingMode,c.contractStatus,c.examineStatus,c.contractWritter from repay r,contract c \n" +

"WHERE c.ID = r.contract_id GROUP BY r.contract_id)as t\n" +

"\n" +

"LEFT JOIN drawmoney d on d.contract_id = t.ID\n" +

"LEFT JOIN borrower b on b.USCC = t.borrow_id\n" +

"LEFT JOIN loan l on l.ID = t.loan_id where 1=1" +

" and t.id = #{id} " +

" and t.projectName = #{projectName} " +

" and t.contractWritter = #{contractWritter} " +

" and loanName = #{loanName} " +

" and borrowName = #{borrowName} " +

" and t.examineStatus = #{examineStatus} "+

" and t.startData > STR_TO_DATE(#{startData},'%Y-%m-%d') "+

" and t.endData < STR_TO_DATE(#{endData},'%Y-%m-%d') "+

" and t.contractStatus = #{contractStatus} "+

" and t.financingMode = #{financingMode} "+

" and t.loanMoney > #{moreThan} " +

" and t.loanMoney < #{lessThan} " +

" and t.loanMoney between #{moreThan} and #{lessThan} " +

" and t.repayWay = #{repayWay} " +

" and t.contractRepayTime > STR_TO_DATE(#{after_contractRepayTime},'%Y-%m-%d') " +

" and t.contractRepayTime < STR_TO_DATE(#{before_contractRepayTime},'%Y-%m-%d') " +

"group by t.id "+

" HAVING 1=1 " +

" and SUM(t.repayed) > #{morethan_repayed} " +

" and SUM(t.repayed) < #{morethan_repayed} " +

" and drawed > #{after_drawed} " +

" and drawed < #{before_drawed} " +

" and interest_repayed > #{after_repayedInterest} " +

" and interest_repayed < #{before_repayedInterest} " +

" and toRepayed > #{after_toRepayed} " +

" and toRepayed < #{before_toRrepayed} " +

// " HAVING SUM(t.repayed) > #{morethan_repayed} " +

// " HAVING SUM(t.repayed) < #{lessthan_repayed} " +

// " HAVING SUM(t.repayed) > #{morethan_repayed} and SUM(t.repayed) < #{lessthan_repayed} " +

// " HAVING drawed > #{after_drawed} " +

// " HAVING drawed < #{before_drawed} " +

// " HAVING drawed > #{after_drawed} and drawed < #{before_drawed} " +

"ORDER BY startData" +

""})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值