我被一个更新查询困住了。我有一个查询
SELECT s_no, loan_id,repayment_date,principal,loan_balance, count(*) as repeatTimes
FROM loan_repayment_plan_mcg
GROUP BY s_no, loan_id, repayment_date,principal,loan_balance
HAVING count(*) > 1
它返回此输出:
s_no loan_id repayment_date principal loan_balance repeatTimes
1 21111 2012-03-13 0.00 5000.00 2
2 21311 2012-04-12 0.00 2000.00 2
3 21111 2012-05-13 500 5000.00 2
4 21111 2012-06-14 0.00 5000.00 3
我想更新loan_balance
乘以repeatTimes
我上面的选择查询,loan_id
并repayment_date
结合在一起形成一个唯一的行。