請教 我在自訂查詢報表語法
SELECT sfa01,sfa03,sfa05,sfa06,sfa062,sfa063,sfa16,sfb09,a.tlf10 as 領料量,a.tlf10 - sfa063 as 領料量減報廢量,sfa06+sfa062-sfa063 -( a.tlf10 - sfa063)as 結存
FROM sfa_file
LEFT OUTER JOIN sfb_file
ON sfa01 = sfb01
LEFT OUTER JOIN
(SELECT DISTINCT tlf01,tlf62,sum( tlf10 * tlf907 * -1 )tlf10 FROM tlf_file
WHERE tlf13 MATCHES 'asfi5*'
AND tlf907 <> 0
GROUP BY tlf01,tlf62 ) a
ON sfa03 = a.tlf01
WHERE tlf01 = sfa03 AND tlf62 = sfa01 and sfb02 = '7' and sfb87 = 'Y' and ( sfb04 <> '8' or sfb04 <> '1' ) AND sfb13 >= '2020/01/01'
直接查詢資料 是可以正常查詢資料
可是執行程式編號 填為填入料號 或工單號 或...(任意欄位) 查詢 就會出錯
未發現表格中有欄位column-name (或SLV尚未加以定義)
請問要如何修正
謝謝
你的sql結構有問題!我已修正了你再試看看.
SELECT a.sfa01,a.sfa03,a.sfa05,a.sfa06,a.sfa062,a.sfa063,a.sfa16,b.sfb09,c.tlf10,c.tlf10 - a.sfa063,a.sfa06+a.sfa062-a.sfa063 -( c.tlf10 - a.sfa063)
FROM sfa_file a
LEFT OUTER JOIN sfb_file b ON a.sfa01 = b.sfb01
LEFT OUTER JOIN (SELECT DISTINCT tlf01,tlf62,sum( tlf10 * tlf907 * -1 )tlf10 FROM tlf_file WHERE tlf13 MATCHES 'asfi5*' AND tlf907 <> 0 GROUP BY tlf01,tlf62 ) c ON a.sfa03 = c.tlf01
WHERE c.tlf01 = a.sfa03 AND c.tlf62 = a.sfa01 and b.sfb02 = '7' and b.sfb87 = 'Y' and ( b.sfb04 <> '8' or b.sfb04 <> '1' ) AND b.sfb13 >= '2020/01/01'
WHERE tlf13 MATCHES 'asfi5*' 改成 tlf13 like 'asfi5%'
'2020/01/01' 改成to_date('2020/01/01','YYYY/MM/DD')
LEFT OUTER JOIN 去掉OUTER
樓上兩位的指令都能在oracle顯示結果
不過這些指令差異好像除了INFORMAX ORACLE有差,也跟使用SQL的查詢工具相關
這報表直接在sfa_file + sfb_file就能取得所有工單資訊,為何還要去異動記錄比對?另完工入庫也沒用來計算?