create view vi_lc_rent_income as (
SELECT RP.CONTRACT_ID                               AS CONTRACT_ID,
       RP.PAYMENT_NUMBER                            AS PAYMENT_NUMBER,
       RP.PLAN_LIST                                 AS PLAN_LIST,
       RP.PLAN_DATE                                 AS PLAN_DATE,
       RP.RENT                                      AS RENT,
       RP.CORPUS                                    AS CORPUS,
       RP.INTEREST                                  AS INTEREST,
       (RP.RENT - ifnull(RI.RENTINCOME, 0))         AS RENT_OVERAGE,
       (RP.CORPUS - ifnull(RI.CORPUSINCOME, 0))     AS CORPUS_OVERAGE,
       (RP.INTEREST - ifnull(RI.INTERESTINCOME, 0)) AS INTEREST_OVERAGE
FROM (APZL.LC_RENT_PLAN RP
LEFT JOIN (
    SELECT APZL.LC_RENT_INCOME.PLAN_ID                                                    AS PLAN_ID,
           (sum(APZL.LC_RENT_INCOME.RENT) + sum(APZL.LC_RENT_INCOME.INTEREST_ADJUST))     AS RENTINCOME,
           sum(APZL.LC_RENT_INCOME.CORPUS)                                                AS CORPUSINCOME,
           (sum(APZL.LC_RENT_INCOME.INTEREST) + sum(APZL.LC_RENT_INCOME.INTEREST_ADJUST)) AS INTERESTINCOME
    FROM APZL.LC_RENT_INCOME
    GROUP BY APZL.LC_RENT_INCOME.PLAN_ID
) RI ON ((RP.ID = RI.PLAN_ID))));

-- comment on column vi_lc_rent_income.contract_id not supported: 合同编号

-- comment on column vi_lc_rent_income.PAYMENT_NUMBER not supported: 投放编号

-- comment on column vi_lc_rent_income.PLAN_LIST not supported: 期次

-- comment on column vi_lc_rent_income.PLAN_DATE not supported: 计划日期

-- comment on column vi_lc_rent_income.RENT not supported: 租金

-- comment on column vi_lc_rent_income.CORPUS not supported: 财务本金

-- comment on column vi_lc_rent_income.INTEREST not supported: 财务租息

