create view vi_cust_person as (
SELECT DISTINCT INFO.CUSTOMERID                 AS CUSTOMERID,
                INFO.CUSTOMERNAME               AS CUSTOMERNAME,
                INFO.CUSTOMERTYPE               AS CUSTOMERTYPE,
                INFO.CERTTYPE                   AS CERTTYPE,
                INFO.CERTID                     AS CERTID,
                PERSON.SEX                      AS SEX,
                PERSON.MOBILE                   AS MOBILE,
                PERSON.LICENSENAME              AS LICENSENAME,
                CO.ITEMNAME                     AS LICENSENAMENAME,
                PERSON.WORKCORP                 AS WORKCORP,
                PERSON.WORKADD                  AS WORKADD,
                PERSON.WORKTEL                  AS WORKTEL,
                PERSON.ENTRYTIME                AS ENTRYTIME,
                PERSON.MAILING_ADDRESS          AS MAILING_ADDRESS,
                PERSON.NATIVEPLACE              AS NATIVEPLACE,
                PERSON.EMERGENCY_CONTACT_PERSON AS EMERGENCY_CONTACT_PERSON,
                PERSON.EMPLOYRECORD             AS EMPLOYRECORD,
                PERSON.EMERGENCY_CONTACT_TEL    AS EMERGENCY_CONTACT_TEL,
                PERSON.INTRO                    AS INTRO,
                PERSON.EDUDEGREE                AS EDUDEGREE,
                PERSON.REMARK                   AS REMARK,
                PERSON.MARRIAGE                 AS MARRIAGE,
                CO1.ITEMNAME                    AS MARRIAGENAME,
                PERSON.POPULATION               AS POPULATION,
                PERSON.CHILDRENS_NUMBER         AS CHILDRENS_NUMBER,
                PERSON.TELEPHONE                AS TELEPHONE,
                PERSON.EDUEXPERIENCE            AS EDUEXPERIENCE,
                CO2.ITEMNAME                    AS EDUEXPERIENCENAME,
                PERSON.PROPERTY_TYPE            AS PROPERTY_TYPE,
                CO3.ITEMNAME                    AS PROPERTY_TYPENAME,
                PERSON.UNIT_NATURE              AS UNIT_NATURE,
                CO4.ITEMNAME                    AS UNIT_NATURENAME,
                PERSON.OCCUPATION               AS OCCUPATION,
                PERSON.MAIN_INCOME              AS MAIN_INCOME,
                CO5.ITEMNAME                    AS MAIN_INCOMENAME,
                PERSON.BEFORE_UNIT_NAME         AS BEFORE_UNIT_NAME,
                PERSON.FAMILYMONTHINCOME        AS FAMILYMONTHINCOME,
                PERSON.OTHER_INCOME             AS OTHER_INCOME,
                ADDRESS.FULLADDRESS             AS FULLADDRESS,
                CTYPE.CUSTTYPE                  AS CUSTTYPE,
                CO6.ITEMNAME                    AS CUSTTYPENAME,
                FAMILYP.NAME                    AS PARTNER_NAME,
                FAMILYP.ASSURE_RELATION         AS PARTNER_ASSURE_RELATION,
                FAMILYP.CERTID                  AS PARTNER_CERTID,
                FAMILYP.SEX                     AS PARTNER_SEX,
                FAMILYP.TEL                     AS PARTNER_TEL,
                FAMILYP.SHUKOU                  AS PARTNER_SHUKOU,
                FAMILYP.SUNAME                  AS PARTNER_SUNAME,
                FAMILYP.SUPHONE                 AS PARTNER_SUPHONE,
                FAMILYP.SPOSITION               AS PARTNER_SPOSITION,
                FAMILYP.SMINCOME                AS PARTNER_SMINCOME,
                FAMILYP.WORKUNIT                AS PARTNER_WORKUNIT,
                FAMILYW.NAME                    AS SPOUSE_NAME,
                FAMILYW.CERTID                  AS SPOUSE_CERTID,
                FAMILYW.SEX                     AS SPOUSE_SEX,
                FAMILYW.TEL                     AS SPOUSE_TEL,
                FAMILYW.PARTNER_                AS SPOUSE_PARTNER,
                FAMILYW.SHUKOU                  AS SPOUSE_SHUKOU,
                CO7.ITEMNAME                    AS SPOUSE_SHUKOUNAME,
                FAMILYW.SUNAME                  AS SPOUSE_SUNAME,
                FAMILYW.SUPHONE                 AS SPOUSE_SUPHONE,
                FAMILYW.SPOSITION               AS SPOUSE_SPOSITION,
                FAMILYW.SMINCOME                AS SPOUSE_SMINCOME,
                FAMILYW.WORKUNIT                AS SPOUSE_WORKUNIT
FROM ((((((((((((((((APZL.CUSTOMER_INFO INFO LEFT JOIN APZL.CUSTOMER_PERSON PERSON ON ((INFO.CUSTOMERID = PERSON.CUSTOMERID))) LEFT JOIN APZL.CUSTOMER_ADDRESS ADDRESS ON ((ADDRESS.CUSTOMERID = convert(INFO.CUSTOMERID USING UTF8)))) LEFT JOIN APZL.CUSTOMER_CERT CERT ON ((CERT.CUSTOMERID = INFO.CUSTOMERID))) LEFT JOIN APZL.CUSTOMER_TYPE CTYPE ON ((CTYPE.CUSTOMERID = INFO.CUSTOMERID))) LEFT JOIN APZL.LB_UNION_LESSEE LUL ON ((LUL.CUSTOMER_ID = INFO.CUSTOMERID))) LEFT JOIN APZL.LB_PROJECT_INFO LPI ON ((LPI.ID = convert(LUL.PROJECT_ID USING UTF8)))) LEFT JOIN APZL.CUSTOMER_FAMILY FAMILYP ON ((
        (convert(FAMILYP.PROJECT_ID USING UTF8) = LPI.ID) AND (FAMILYP.PARTNER_ = 'Y') AND
        isnull(FAMILYP.SPOUSE_)))) LEFT JOIN APZL.CUSTOMER_FAMILY FAMILYW ON (((convert(FAMILYW.PROJECT_ID USING UTF8) = LPI.ID) AND (FAMILYW.SPOUSE_ = 'Y')))) LEFT JOIN APZL.CODE_LIBRARY CO ON (((CO.CODENO = 'customer_driver') AND (CO.ITEMNO = PERSON.LICENSENAME)))) LEFT JOIN APZL.CODE_LIBRARY CO1 ON (((CO1.CODENO = 'marry') AND (CO1.ITEMNO = PERSON.MARRIAGE)))) LEFT JOIN APZL.CODE_LIBRARY CO2 ON (((CO2.CODENO = 'Education') AND (CO2.ITEMNO = PERSON.EDUEXPERIENCE)))) LEFT JOIN APZL.CODE_LIBRARY CO3 ON (((CO3.CODENO = 'Property_type') AND (CO3.ITEMNO = PERSON.PROPERTY_TYPE)))) LEFT JOIN APZL.CODE_LIBRARY CO4 ON (((CO4.CODENO = 'Unit_nature') AND (CO4.ITEMNO = PERSON.UNIT_NATURE)))) LEFT JOIN APZL.CODE_LIBRARY CO5 ON (((CO5.CODENO = 'main_income') AND (CO5.ITEMNO = PERSON.MAIN_INCOME)))) LEFT JOIN APZL.CODE_LIBRARY CO6 ON (((CO6.CODENO = 'CustomerType') AND (CO6.ITEMNO = CTYPE.CUSTTYPE))))
LEFT JOIN APZL.CODE_LIBRARY CO7 ON (((CO7.CODENO = 'spouse_hukou') AND (CO7.ITEMNO = FAMILYW.SHUKOU))))
WHERE (INFO.CUSTOMERTYPE = '03'));

-- comment on column vi_cust_person.customerid not supported: 客户编号

-- comment on column vi_cust_person.customername not supported: 客户名称

-- comment on column vi_cust_person.customertype not supported: 客户类别

-- comment on column vi_cust_person.certtype not supported: 证件类型

-- comment on column vi_cust_person.certid not supported: 证件号

-- comment on column vi_cust_person.sex not supported: 性别

-- comment on column vi_cust_person.mobile not supported: 手机号

-- comment on column vi_cust_person.LICENSENAME not supported: 驾驶证姓名

-- comment on column vi_cust_person.WORKCORP not supported: 单位名称

-- comment on column vi_cust_person.WORKADD not supported: 单位地址

-- comment on column vi_cust_person.WORKTEL not supported: 单位电话

-- comment on column vi_cust_person.ENTRYTIME not supported: 入职时间

-- comment on column vi_cust_person.Mailing_Address not supported: 邮寄地址

-- comment on column vi_cust_person.NATIVEPLACE not supported: 户籍地址

-- comment on column vi_cust_person.EMERGENCY_CONTACT_PERSON not supported: 紧急联系人

-- comment on column vi_cust_person.EMPLOYRECORD not supported: 工作履历

-- comment on column vi_cust_person.EMERGENCY_CONTACT_TEL not supported: 紧急联系电话

-- comment on column vi_cust_person.INTRO not supported: 个人情况简介

-- comment on column vi_cust_person.EDUDEGREE not supported: 最高学位

-- comment on column vi_cust_person.REMARK not supported: 备注

-- comment on column vi_cust_person.MARRIAGE not supported: 婚姻状况

-- comment on column vi_cust_person.POPULATION not supported: 家庭人口数

-- comment on column vi_cust_person.childrens_number not supported: 子女人数

-- comment on column vi_cust_person.telephone not supported: 固定电话

-- comment on column vi_cust_person.EDUEXPERIENCE not supported: 最高学历

-- comment on column vi_cust_person.Property_type not supported: 房产类型

-- comment on column vi_cust_person.Unit_nature not supported: 单位性质

-- comment on column vi_cust_person.OCCUPATION not supported: 职业

-- comment on column vi_cust_person.main_income not supported: 主要收入

-- comment on column vi_cust_person.before_unit_name not supported: 前工作单位名称

-- comment on column vi_cust_person.FAMILYMONTHINCOME not supported: 家庭月收入

-- comment on column vi_cust_person.other_income not supported: 其他收入

-- comment on column vi_cust_person.fulladdress not supported: 地址全名

-- comment on column vi_cust_person.custtype not supported: 客户类别

-- comment on column vi_cust_person.Partner_name not supported: 姓名

-- comment on column vi_cust_person.Partner_ASSURE_RELATION not supported: 关系

-- comment on column vi_cust_person.Partner_certid not supported: 证件号码

-- comment on column vi_cust_person.Partner_SEX not supported: 性别

-- comment on column vi_cust_person.Partner_tel not supported: 联系电话

-- comment on column vi_cust_person.Partner_shukou not supported: 户口-配偶

-- comment on column vi_cust_person.Partner_suname not supported: 单位名称-配偶

-- comment on column vi_cust_person.Partner_suphone not supported: 单位电话-配偶

-- comment on column vi_cust_person.Partner_sposition not supported: 职位—配偶

-- comment on column vi_cust_person.Partner_smincome not supported: 月收入——配偶

-- comment on column vi_cust_person.Partner_workunit not supported: 工作单位

-- comment on column vi_cust_person.SPOUSE_name not supported: 姓名

-- comment on column vi_cust_person.SPOUSE_certid not supported: 证件号码

-- comment on column vi_cust_person.SPOUSE_SEX not supported: 性别

-- comment on column vi_cust_person.SPOUSE_tel not supported: 联系电话

-- comment on column vi_cust_person.SPOUSE_Partner not supported: 是否共同申请人

-- comment on column vi_cust_person.SPOUSE_shukou not supported: 户口-配偶

-- comment on column vi_cust_person.SPOUSE_suname not supported: 单位名称-配偶

-- comment on column vi_cust_person.SPOUSE_suphone not supported: 单位电话-配偶

-- comment on column vi_cust_person.SPOUSE_sposition not supported: 职位—配偶

-- comment on column vi_cust_person.SPOUSE_smincome not supported: 月收入——配偶

-- comment on column vi_cust_person.SPOUSE_workunit not supported: 工作单位

