create view vi_card_deduct_data as (
SELECT LCDD.SERIALNO                                                                     AS SERIALNO,
       VLRP.ID                                                                           AS CONTRACT_ID,
       LCDD.ID                                                                           AS CARDDEDUCT_ID,
       LCDD.DEDUCT_DOCID                                                                 AS DEDUCT_DOCID,
       VLRP.CONTRACT_NUMBER                                                              AS CONTRACT_NUMBER,
       LCDD.PAYMENT_NUMBER                                                               AS PAYMENT_NUMBER,
       VLRP.CUSTOMERNAME                                                                 AS CUSTOMERNAME,
       LLI.LEASE_ACC_BANK                                                                AS LEASE_ACC_BANK,
       LCDD.OWNACC_NUMBER                                                                AS OWNACC_NUMBER,
       LCDD.OWN_ACCOUNT                                                                  AS OWN_ACCOUNT,
       LCDD.CLIENT_BANK                                                                  AS CLIENT_BANK,
       LCDD.CLIENT_ACCOUNT                                                               AS CLIENT_ACCOUNT,
       LCDD.CLIENT_ACC_NUMBER                                                            AS CLIENT_ACC_NUMBER,
       VLRP.PLAN_DATE                                                                    AS PLAN_DATE,
       LCDD.PLAN_LIST                                                                    AS PLAN_LIST,
       LCDD.FEE_TYPE                                                                     AS FEE_TYPE,
       LCDD.ENDDATE                                                                      AS ENDDATE,
       LCDD.ACTUAL_DEBIT_AMT                                                             AS ACTUAL_DEBIT_AMT,
       (CASE WHEN (LCDD.FEE_TYPE = '租金') THEN VLRP.RENT_OVER ELSE VLRP.PENALTY_OVER END) AS OVER_MONEY,
       LCDD.TRANSTATUS                                                                   AS TRANSTATUS,
       LCDD.RESULTDESC                                                                   AS RESULTDESC,
       LR.CARDDEDUCT_STATUS                                                              AS CARDDEDUCT_STATUS
FROM (((APZL.LC_CARD_DEDUCT_DATA LCDD LEFT JOIN APZL.VI_LC_RENT_PLAN VLRP ON (((VLRP.PAYMENT_NUMBER = LCDD.PAYMENT_NUMBER) AND (VLRP.PLAN_LIST = LCDD.PLAN_LIST)))) LEFT JOIN (
    SELECT LRI.CARDDEDUCT_ID AS CARDDEDUCT_ID, LRI.CARDDEDUCT_STATUS AS CARDDEDUCT_STATUS
    FROM APZL.LC_RENT_INCOME LRI
    WHERE (LRI.ROLL_BACK = '0')
    UNION
    SELECT LRIT.CARDDEDUCT_ID AS CARDDEDUCT_ID, LRIT.CARDDEDUCT_STATUS AS CARDDEDUCT_STATUS
    FROM APZL.LC_RENT_INCOME_TEMP LRIT
    WHERE ((LRIT.ROLL_BACK = '0') AND (LRIT.IS_FLOWING = '0'))
) LR ON ((LR.CARDDEDUCT_ID = LCDD.ID)))
LEFT JOIN APZL.LB_LESSOR_INFO LLI ON ((LLI.CONTRACT_ID = VLRP.ID))));

-- comment on column vi_card_deduct_data.serialno not supported: 序号

-- comment on column vi_card_deduct_data.contract_id not supported: 标识

-- comment on column vi_card_deduct_data.carddeduct_id not supported: 标识

-- comment on column vi_card_deduct_data.deduct_docid not supported: 卡扣文件编号

-- comment on column vi_card_deduct_data.contract_number not supported: 业务合同号

-- comment on column vi_card_deduct_data.payment_number not supported: 投放编号

-- comment on column vi_card_deduct_data.lease_acc_bank not supported: 开户银行（甲方）

-- comment on column vi_card_deduct_data.ownacc_number not supported: 本方账号

-- comment on column vi_card_deduct_data.own_account not supported: 本方账户

-- comment on column vi_card_deduct_data.client_bank not supported: 对方银行

-- comment on column vi_card_deduct_data.client_account not supported: 对方账户

-- comment on column vi_card_deduct_data.client_acc_number not supported: 对方账号

-- comment on column vi_card_deduct_data.plan_date not supported: 计划日期

-- comment on column vi_card_deduct_data.plan_list not supported: 期次

-- comment on column vi_card_deduct_data.fee_type not supported: 费用类型

-- comment on column vi_card_deduct_data.enddate not supported: 扣款日期

-- comment on column vi_card_deduct_data.actual_debit_amt not supported: 到账金额

-- comment on column vi_card_deduct_data.transtatus not supported: 交易状态

-- comment on column vi_card_deduct_data.resultdesc not supported: 交易结果

