请帮忙!!!我正在使用 SQL Dev 2.1,我想找到最新的日期并加入表格。我的查询如下:-
我想获得最新的 DEBT_COLLECTION_STEPS_V.TRANSACTION_DATE,因为有多个日期与相同的发票号相关,但针对 DEBT_COLLECTION_STEPS_V.DESCRIPTION 发布了不同的评论。
SELECT AR_INVOICE_INQ_V.CLIENT CLIENT,
AR_INVOICE_INQ_V.CLI_NAME CLI_NAME,
AR_INVOICE_INQ_V.PARTNER PARTNER,
AR_INVOICE_INQ_V.PAR_NAME PAR_NAME,
AR_INVOICE_INQ_V.MANAGER MANAGER,
AR_INVOICE_INQ_V.REFERENCE REFERENCE,
AR_INVOICE_INQ_V.STATUS_CODE STATUS_CODE,
AR_INVOICE_INQ_V.INVOICE_DATE INVOICE_DATE,
AR_INVOICE_INQ_V.TIME_BILLED TIME_BILLED,
AR_INVOICE_INQ_V.GROUP_CLIENT_CODE GROUP_CLIENT_CODE,
AR_INVOICE_INQ_V.GRPCLI_NAME GRPCLI_NAME,
AR_INVOICE_INQ_V.INVOICE_BALANCE,
SUBSTR(AR_INVOICE_INQ_V.MANAGER, 3, 2) CENTRE,
DEBT_COLLECTION_STEPS_V.DESCRIPTION,
MAX (BILLING_TRANSACTIONS_V.SEQUENCE_CODE),
DEBT_COLLECTION_STEPS_V.TRANSACTION_DATE
FROM AR_INVOICE_INQ_V
LEFT JOIN DEBT_COLLECTION_STEPS_V
ON DEBT_COLLECTION_STEPS_V.INVOICE_NUMBER = AR_INVOICE_INQ_V.REFERENCE
JOIN BILLING_TRANSACTIONS_V
ON BILLING_TRANSACTIONS_V.INVOICE_OR_CN_NUMBER = AR_INVOICE_INQ_V.REFERENCE
WHERE AR_INVOICE_INQ_V.INVOICE_BALANCE >0
AND AR_INVOICE_INQ_V.MANAGER BETWEEN 'AAAA' AND 'AZZZ'
GROUP BY AR_INVOICE_INQ_V.CLIENT,
AR_INVOICE_INQ_V.CLI_NAME,
AR_INVOICE_INQ_V.PARTNER,
AR_INVOICE_INQ_V.PAR_NAME,
AR_INVOICE_INQ_V.MANAGER,
AR_INVOICE_INQ_V.REFERENCE,
AR_INVOICE_INQ_V.STATUS_CODE,
AR_INVOICE_INQ_V.INVOICE_DATE,
AR_INVOICE_INQ_V.TIME_BILLED,
AR_INVOICE_INQ_V.GROUP_CLIENT_CODE,
AR_INVOICE_INQ_V.GRPCLI_NAME,
AR_INVOICE_INQ_V.INVOICE_BALANCE,
SUBSTR(AR_INVOICE_INQ_V.MANAGER, 3, 2),
DEBT_COLLECTION_STEPS_V.DESCRIPTION,
DEBT_COLLECTION_STEPS_V.TRANSACTION_DATE;