UPDATE T_ER_REIMBURSEBILL SET FINVOICEOFFSETAMOUNT = 0 WHERE FINVOICEOFFSETAMOUNT IS NULL ;
UPDATE T_ER_REIMBURSEBILL BILL SET FINVOICEOFFSETAMOUNT = (SELECT SUM(TI.FOFFSETAMOUNT) FROM T_ER_INVOICEINFO TI WHERE TI.FID = BILL.FID)
WHERE EXISTS (SELECT 1 FROM T_ER_INVOICEINFO TI2 WHERE BILL.FID = TI2.FID);

UPDATE T_ER_DAILYREIMBURSEBILL SET FINVOICEOFFSETAMOUNT = 0 WHERE FINVOICEOFFSETAMOUNT IS NULL ;
UPDATE T_ER_DAILYREIMBURSEBILL BILL SET FINVOICEOFFSETAMOUNT = (SELECT SUM(TI.FOFFSETAMOUNT) FROM T_ER_INVOICEINFO TI WHERE TI.FID = BILL.FID)
WHERE EXISTS (SELECT 1 FROM T_ER_INVOICEINFO TI2 WHERE BILL.FID = TI2.FID);

UPDATE T_ER_PUBREIMBILL SET FINVOICEOFFSETAMOUNT = 0 WHERE FINVOICEOFFSETAMOUNT IS NULL ;
UPDATE T_ER_PUBREIMBILL BILL SET FINVOICEOFFSETAMOUNT = (SELECT SUM(TI.FOFFSETAMOUNT) FROM T_ER_PUBREIMINVOICEINFO TI WHERE TI.FID = BILL.FID)
WHERE EXISTS (SELECT 1 FROM T_ER_PUBREIMINVOICEINFO TI2 WHERE BILL.FID = TI2.FID);