我有三个表(TABLE_A、TABLE_B、TABLE_C),我在 C_MAIN_REF 上加入它们。TABLE_B 有多个条目,我只需要返回一个,不管哪个?
有任何想法吗?
编辑:
SELECT C.C_UNIT_CODE as BU,'EPLC' as PRODUCT, A.BENE_NM as CUSTOMER, A.C_MAIN_REF,
A.C_TRX_REF, A.PRES_CCY, TO_CHAR(A.PRES_AMT) AS PRES_AMT, A.PRES_DT AS PRES_DATE,
A.DOC_STAT, '' AS APPL_RESPONSE, A.SETTLE_STATUS as SETTLE_STATUS
FROM EPLC_EM_NEGO A
INNER JOIN CPYT_SCHEDULE B
ON a.C_MAIN_REF = b.C_MAIN_REF AND ROWNUM =1
INNER JOIN EPLC_MASTER C
ON a.C_MAIN_REF = c.C_MAIN_REF
WHERE a.CLS_DRWG_FLG = 'NO' AND b.CPYT_UNPAID_FLAG = 'T'
以上是我正在使用的当前查询,但问题是我不想要的 CPYT_SCHEDULE 中有多个条目,因此连接应该只包含 CPYT_SCHEDULE 表中的一行;
目前以上回报
BU PRODUCT CUSTOMER C_MAIN_REF C_TRX_REF PRES_CCY PRES_AMT PRES_DATE DOC_STAT SETTLE_STATUS
------------ ---------------------------------------------------- -------- --------- --------- ------------ -------------
GB01 EPLC Finance Customer No. 5 XL000053GB01 XL000053GB01-01 USD 90000 24-AUG-12 COMPLIANT Settle
GB01 EPLC Finance Customer No. 5 XL000053GB01 XL000053GB01-01 USD 90000 24-AUG-12 COMPLIANT Settle
GB01 EPLC Finance Customer No. 5 XL000053GB01 XL000053GB01-01 USD 90000 24-AUG-12 COMPLIANT Settle
GB01 EPLC Finance Customer No. 5 XL000053GB01 XL000053GB01-01 USD 90000 24-AUG-12 COMPLIANT Settle
但所需的输出是
BU PRODUCT CUSTOMER C_MAIN_REF C_TRX_REF PRES_CCY PRES_AMT PRES_DATE DOC_STAT SETTLE_STATUS
------------ ---------------------------------------------------- -------- --------- --------- ------------ -------------
GB01 EPLC Finance Customer No. 5 XL000053GB01 XL000053GB01-01 USD 90000 24-AUG-12 COMPLIANT Settle