-1
SELECT CU.CUST_CODE
FROM AR_CUSTOMERS CU
WHERE CU.CUST_CODE = TM.CUST_CODE
UNION
SELECT ITS.ITEMS_CODE
FROM AR_ITEMS ITS
WHERE ITS.ITEMS_CODE = TM.ITEM_CODE
UNION
SELECT ITS.ITEMS_NAME
FROM AR_ITEMS ITS
WHERE TM.INVOICE_NO = TD.INVOICE_NO AND ITS.ITEMS_CODE = TD.ITEM_CODE
UNION
SELECT TO_CHAR(TM.JOB_DATE,'MON-YY')MON FROM AR_TRANS_MASTER TM
UNION
SELECT TO_CHAR(TM.JOB_DATE,'MM-YY')MM FROM AR_TRANS_MASTER TM
UNION
SELECT SUM(TD.QUANTITY)QUANTITY, SUM(TD.PRICE)UNIT
FROM AR_TRANS_DETAIL TD
WHERE ITS.ITEMS_CODE = TD.ITEM_CODE
AND
TM.JOB_DATE BETWEEN :STARTDATE AND :STOPDATE
GROUP BY
CU.CUST_CODE,ITS.ITEMS_CODE,ITS.ITEMS_NAME,TO_CHAR(TM.JOB_DATE,'MON-YY'),TO_CHAR(TM.JOB_DATE,'MM-YY')
ORDER BY
MM ASC;
ORA-00904: 「以舊換新」, 「CUST_CODE」:無效的標識符 00904. 00000 - 「%S:無效的標識符」 *原因:
*行動:在錯誤行:3列:22如何糾正這個錯誤
您無法訪問TM.CUST_CODE。在進行UNION時,每個SELECT都相互「隔離」。 – jarlh
您還可以從聯合的每個分支中獲取不同的數據 - 不同的數據類型,甚至不同數量的列。當然,你打算把這些表加在一起,而不是聯合起來? –