db2 如何修复[SQL0811] SELECT多行的结果

b0zn9rqh  于 2022-11-07  发布在  DB2
关注(0)|答案(2)|浏览(184)

嗨,伙计们,我遇到了一个关于DB2上SQL查询的问题,你们能帮助我吗?
这是我的代码。[SQL0811] SELECT多行的结果。

SELECT
        VIEW_FCLT_REGISTER.BUSINESS_GROUP_NAME AS FCLT_REGISTER_BUSINESS_GROUP_NAME,
        VIEW_FCLT_REGISTER.ID_FACILITY_NO      AS ID_FACILITY_NO,
        CASE VIEW_FCLT_REGISTER."FCLT_STATUS"
            WHEN 'M'
            THEN 'Amendment'
            WHEN 'A'
            THEN 'Approved'
            WHEN 'F'
            THEN 'Closed'
            WHEN 'C'
            THEN 'Created'
            WHEN 'Y'
            THEN 'Delete'
            WHEN 'E'
            THEN 'Expired'
            WHEN 'I'
            THEN 'Incompleted'
            WHEN 'N'
            THEN 'New Facility'
            WHEN 'O'
            THEN 'Operational'
            WHEN 'P'
            THEN 'Pending'
            WHEN 'L'
            THEN 'Ready For Closing'
            WHEN 'D'
            THEN 'Ready For Disburse'
            WHEN 'R'
            THEN 'Recovery'
            WHEN 'Z'
            THEN 'Reject At Approval'
            WHEN 'U'
            THEN 'Restructure'
            WHEN 'V'
            THEN 'Reviewed'
            WHEN 'T'
            THEN 'Terminated'
            WHEN 'W'
            THEN 'Waiting For Disburse'
        END                                           AS FCLT_REGISTER_STATUS,
        VIEW_FCLT_REGISTER.CLOSE_DATE                                              AS FCLT_CLOSING_DATE,
        CONCAT (VIEW_FCLT_REGISTER.NAME , CONCAT (', ', VIEW_FCLT_REGISTER.COMPANY_TYPE)) AS
                               LESSEE_NAME,
        OBJECT_LEASE."NAME"               AS ASSET_DESCRIPTION,
        VIEW_OBJECT_LAD."OWNER_NAME"      AS VIEW_OBJECT_LAD_OWNER_NAME,
        VIEW_OBJECT_LAD."ADDRESS"         AS VIEW_OBJECT_LAD_ADDRESS,
        PRM_CITY.DESCRIPTION              AS CITY,
        VIEW_OBJECT_LAD."DOCUMENT_STATUS" AS VIEW_OBJECT_LAD_DOCUMENT_STATUS,
        (
            SELECT
                FCLT_OBJECT_LEASE_INFO."INFORMATION" AS FCLT_OBJECT_LEASE_INFO_FID_CODE
            FROM
                "BTMU"."FCLT_OBJECT_LEASE_INFO" FCLT_OBJECT_LEASE_INFO
            INNER JOIN
                "BTMU"."PRM_GENERIC" PRM_GENERIC
            ON
                FCLT_OBJECT_LEASE_INFO."FID_CODE" = PRM_GENERIC."ID_GENERIC"
            WHERE
                PRM_GENERIC."DESCRIPTION" = 'Chasis No'
            AND FCLT_OBJECT_LEASE_INFO.FID_OBJECT_LEASE = VIEW_OBJECT_LAD.FID_OBJECT_LEASE) AS
        CHASIS_NO,
        (
            SELECT
                FCLT_OBJECT_LEASE_INFO."INFORMATION" AS FCLT_OBJECT_LEASE_INFO_FID_CODE
            FROM
                "BTMU"."FCLT_OBJECT_LEASE_INFO" FCLT_OBJECT_LEASE_INFO
            INNER JOIN
                "BTMU"."PRM_GENERIC" PRM_GENERIC
            ON
                FCLT_OBJECT_LEASE_INFO."FID_CODE" = PRM_GENERIC."ID_GENERIC"
            WHERE
                PRM_GENERIC."DESCRIPTION" = 'Engine No'
            AND FCLT_OBJECT_LEASE_INFO.FID_OBJECT_LEASE = VIEW_OBJECT_LAD.FID_OBJECT_LEASE) AS
        ENGINE_NO,
        (
            SELECT
                FCLT_OBJECT_LEASE_INFO."INFORMATION" AS FCLT_OBJECT_LEASE_INFO_FID_CODE
            FROM
                "BTMU"."FCLT_OBJECT_LEASE_INFO" FCLT_OBJECT_LEASE_INFO
            INNER JOIN
                "BTMU"."PRM_GENERIC" PRM_GENERIC
            ON
                FCLT_OBJECT_LEASE_INFO."FID_CODE" = PRM_GENERIC."ID_GENERIC"
            WHERE
                PRM_GENERIC."DESCRIPTION" = 'Police No'
            AND FCLT_OBJECT_LEASE_INFO.FID_OBJECT_LEASE = VIEW_OBJECT_LAD.FID_OBJECT_LEASE) AS
        POLICE_NO,
        (
            SELECT
                FCLT_OBJECT_LEASE_INFO."INFORMATION" AS FCLT_OBJECT_LEASE_INFO_FID_CODE
            FROM
                "BTMU"."FCLT_OBJECT_LEASE_INFO" FCLT_OBJECT_LEASE_INFO
            INNER JOIN
                "BTMU"."PRM_GENERIC" PRM_GENERIC
            ON
                FCLT_OBJECT_LEASE_INFO."FID_CODE" = PRM_GENERIC."ID_GENERIC"
            WHERE
                PRM_GENERIC."DESCRIPTION" = 'Serial Number'
            AND FCLT_OBJECT_LEASE_INFO.FID_OBJECT_LEASE = VIEW_OBJECT_LAD.FID_OBJECT_LEASE) AS
                                           SERIAL_NO,
        VIEW_OBJECT_LAD."RECEIVED_DATE" AS VIEW_OBJECT_LAD_RECEIVED_DATE,
        FA_SUPPLIER_ASSET."NAME"        AS FA_SUPPLIER_ASSET_NAME
    FROM
        BTMU.VIEW_OBJECT_LAD VIEW_OBJECT_LAD
    INNER JOIN
        BTMU.PRM_GENERIC PRM_GENERIC
    ON
        PRM_GENERIC.ID_GENERIC = VIEW_OBJECT_LAD.FID_CODE
    INNER JOIN
        BTMU.FCLT_OBJECT_LEASE OBJECT_LEASE
    ON
        OBJECT_LEASE.ID_OBJECT_LEASE = VIEW_OBJECT_LAD.FID_OBJECT_LEASE
    INNER JOIN
        BTMU.VIEW_FCLT_REGISTER VIEW_FCLT_REGISTER
    ON
        VIEW_FCLT_REGISTER.ID_FACILITY_NO = OBJECT_LEASE.FID_FACILITY_NO
    INNER JOIN
        BTMU.FA_SUPPLIER_ASSET FA_SUPPLIER_ASSET
    ON
        OBJECT_LEASE."FID_SUPPLIER_ASSET" = FA_SUPPLIER_ASSET."ID_SUPPLIER_ASSET"
    INNER JOIN
        BTMU.PRM_GENERIC PRM_CITY
    ON
        OBJECT_LEASE."FID_CITY" = PRM_CITY."ID_GENERIC"
    WHERE
        VIEW_FCLT_REGISTER."STATUS" = 'A'
    AND UPPER(PRM_GENERIC.DESCRIPTION) LIKE UPPER('BPKB')
    AND VIEW_OBJECT_LAD.STATUS = 'A'
    AND VIEW_OBJECT_LAD.DOCUMENT_STATUS = 'A'
8ulbf1ek

8ulbf1ek1#

任何子查询(选择内部的选择)都可能返回多行,具体取决于连接。
为所有选择查询添加前1个查询

brjng4g3

brjng4g32#

使用“仅获取前1行”,例如:从表中选择列1、列2、...只提取前1行

相关问题