0

我想尽办法做到这一点。目前我有 3 个单独的查询。出于自动化目的,我需要在一个输出中获得这三个查询的结果,我似乎无法正确加入它们以获得预期的结果。

问题 1:

SELECT OH.EXTN_HOST_ORDER_REF,
       OL.EXTN_HOST_ORDER_LINE_REF,
       OL.ORIGINAL_ORDERED_QTY,
       OL.EXTN_TENDER_QUANTITY,
       OL.EXTN_CUM_PICK_QTY,
       OL.SHIPPED_QUANTITY,
       OL.EXTN_REFUND_QTY
FROM   YFS_ORDER_HEADER OH,
       YFS_ORDER_LINE OL
WHERE  OH.ORDER_HEADER_KEY = OL.ORDER_HEADER_KEY
       AND OH.DOCUMENT_TYPE = '0001'
       AND OH.EXTN_HOST_ORDER_REF = 'xxxxxxxxxxx'
ORDER  BY PL.EXTN_HOST_ORDER_LINE_REF ASC;

问题 2:

SELECT RS.STATUS_QUANTITY AS RETURNED_QTY
FROM   YFS_ORDER_HEADER OH,
       YFS_ORDER_LINE OL,
       YFS_ORDER_RELEASE_STATUS RS
WHERE  OH.ORDER_HEADER_KEY = OL.ORDER_HEADER_KEY
       AND OL.ORDER_LINE_KEY = RS.ORDER_LINE_KEY
       AND RS.STATUS = '3700.02'
       AND OH.EXTN_HOST_ORDER_REF = 'xxxxxxxxxxx';

问题 3

SELECT RS.STATUS_QUANTITY AS CANCELLED_QTY
FROM   YFS_ORDER_HEADER OH,
       YFS_ORDER_LINE OL,
       YFS_ORDER_RELEASE_STATUS RS
WHERE  OH.ORDER_HEADER_KEY = OL.ORDER_HEADER_KEY
       AND OL.ORDER_LINE_KEY = RS.ORDER_LINE_KEY
       AND RS.STATUS = '9000'
       AND OH.EXTN_HOST_ORDER_REF = 'xxxxxxxxxxx'; 

在查询 2 和 3 中不存在数据的情况下,查询应显示 NULL 值。

提前感谢您的帮助和建议!

4

1 回答 1

0

如果您被允许同时显示退回和取消的数量,那么下面的简单编辑应该可以工作。希望这可以帮助。

  SELECT oh.extn_host_order_ref,
         ol.extn_host_order_line_ref,
         ol.original_ordered_qty,
         ol.extn_tender_quantity,
         ol.extn_cum_pick_qty,
         ol.shipped_quantity,
         ol.extn_refund_qty,
         DECODE (rs.status, '3700.02', rs.status_quantity) AS returned_qty,
         DECODE (rs.status, '9000', rs.status_quantity) AS cancelled_qty
    FROM yfs_order_header oh
         INNER JOIN yfs_order_line ol
            ON oh.order_header_key = ol.order_header_key
         LEFT OUTER JOIN yfs_order_release_status rs
            ON ol.order_line_key = rs.order_line_key
   WHERE oh.document_type = '0001' AND oh.extn_host_order_ref = 'xxxxxxxxxxx'
ORDER BY pl.extn_host_order_line_ref ASC;
于 2013-10-22T18:17:59.210 回答