create view vi_normalsettle_contract as SELECT LCI.ID AS CONTRACT_ID, LCI.CONTRACT_STATUS AS CONTRACT_STATUS, LCC.INCOME_NUMBER AS INCOME_NUMBER
FROM ((((APZL.LB_CONTRACT_INFO LCI LEFT JOIN APZL.LC_RENT_PLAN LRP ON ((LRP.CONTRACT_ID = LCI.ID))) LEFT JOIN APZL.LC_RENT_INCOME LRI ON (((LRI.CONTRACT_ID = LRP.CONTRACT_ID) AND (LRI.PLAN_LIST = LRP.PLAN_LIST)))) LEFT JOIN APZL.LC_CONTRACT_CONDITION LCC ON ((LCC.CONTRACT_ID = LRI.CONTRACT_ID)))
LEFT JOIN APZL.BUSINESS_STATUS BS ON ((BS.CONTRACT_NUMBER = LCI.CONTRACT_NUMBER)))
WHERE ((NOT (LCI.CONTRACT_NUMBER IN (
    SELECT APZL.BUSINESS_STATUS.CONTRACT_NUMBER FROM APZL.BUSINESS_STATUS WHERE (APZL.BUSINESS_STATUS.BUSINESS_STATUS = '51')
))) AND (LCI.CONTRACT_STATUS = '31'))
GROUP BY LRP.CONTRACT_ID
HAVING ((sum(LRI.RENT) >= sum(LRP.RENT)) AND (max(LRP.PLAN_LIST) = LCC.INCOME_NUMBER) AND (max(LRI.PLAN_LIST) = LCC.INCOME_NUMBER));

-- comment on column vi_normalsettle_contract.contract_id not supported: 编号

-- comment on column vi_normalsettle_contract.contract_status not supported: 合同状态

-- comment on column vi_normalsettle_contract.income_number not supported: 还租次数

