45 lines
3.2 KiB
SQL
45 lines
3.2 KiB
SQL
create view vi_settlement_of_data as (
|
|
SELECT LRI.HIRE_DATE AS HIRE_DATE,
|
|
O.CONTRACT_NO AS CONTRACT_NO,
|
|
(CASE CI.CUSTOMERTYPE WHEN '01' THEN CC.ENTERPRISENAME WHEN '03' THEN CP.FULLNAME END) AS FULLNAME,
|
|
(CASE CI.CUSTOMERTYPE WHEN '01' THEN CC.CERTID WHEN '03' THEN CP.CERTID END) AS CERTID,
|
|
LEC.FRAME_NUMBER AS FRAME_NUMBER,
|
|
LEC.ENGINE_NUMBER AS ENGINE_NUMBER,
|
|
LEC.LICENSE_PLATE_NUMBER AS LICENSE_PLATE_NUMBER,
|
|
DI.DISTRIBUTOR_NAME AS DISTRIBUTOR_NAME,
|
|
DI.CITY AS CITY,
|
|
DI.LOCATION AS LOCATION,
|
|
DI.DISTRIBUTOR_NO AS DISTRIBUTOR_NO,
|
|
LPI.INPUTNAME AS INPUTNAME,
|
|
LPI.INPUTTEL AS INPUTTEL
|
|
FROM ((((((((APZL.LB_CONTRACT_INFO O LEFT JOIN APZL.LB_UNION_LESSEE LUL ON ((O.PROJECT_ID = LUL.PROJECT_ID))) LEFT JOIN APZL.CUSTOMER_INFO CI ON ((CI.CUSTOMERID = LUL.CUSTOMER_ID))) LEFT JOIN APZL.CUSTOMER_PERSON CP ON ((CP.CUSTOMERID = LUL.CUSTOMER_ID))) LEFT JOIN APZL.CUSTOMER_COMPANY CC ON ((CC.CUSTOMERID = LUL.CUSTOMER_ID))) LEFT JOIN APZL.LB_EQUIPMENT_CAR LEC ON ((convert(O.ID USING UTF8) = LEC.CONTRACT_ID))) LEFT JOIN APZL.LB_PROJECT_INFO LPI ON ((convert(O.PROJECT_ID USING UTF8) = LPI.ID))) LEFT JOIN APZL.DISTRIBUTOR_INFO DI ON ((DI.DISTRIBUTOR_NO = LPI.DISTRIBUTOR_ID)))
|
|
LEFT JOIN (
|
|
SELECT APZL.LC_RENT_INCOME.CONTRACT_ID AS CONTRACT_ID, max(APZL.LC_RENT_INCOME.HIRE_DATE) AS HIRE_DATE
|
|
FROM APZL.LC_RENT_INCOME
|
|
GROUP BY APZL.LC_RENT_INCOME.CONTRACT_ID
|
|
) LRI ON ((LRI.CONTRACT_ID = O.ID)))
|
|
WHERE ((O.CONTRACT_STATUS = '100') OR (O.CONTRACT_STATUS = '105')));
|
|
|
|
-- comment on column vi_settlement_of_data.hire_date not supported: 核销日期
|
|
|
|
-- comment on column vi_settlement_of_data.contract_no not supported: 合同号
|
|
|
|
-- comment on column vi_settlement_of_data.FRAME_NUMBER not supported: 车架号
|
|
|
|
-- comment on column vi_settlement_of_data.ENGINE_NUMBER not supported: 发动机号
|
|
|
|
-- comment on column vi_settlement_of_data.LICENSE_PLATE_NUMBER not supported: 车牌号码
|
|
|
|
-- comment on column vi_settlement_of_data.distributor_name not supported: 经销商名称
|
|
|
|
-- comment on column vi_settlement_of_data.CITY not supported: 城市
|
|
|
|
-- comment on column vi_settlement_of_data.LOCATION not supported: 地址
|
|
|
|
-- comment on column vi_settlement_of_data.distributor_no not supported: 经销商编码
|
|
|
|
-- comment on column vi_settlement_of_data.inputName not supported: 报单人姓名
|
|
|
|
-- comment on column vi_settlement_of_data.inputTel not supported: 报单人电话
|
|
|