我很感激我的代碼任何幫助,我不斷收到一個錯誤SQL UPDATE錯誤
SQL命令無法正常從蟾蜍結束」。
UPDATE GS_MRC_EXISTING GME
SET GME.GROSS_LAST = STC.SALES
WITH STC AS
(
SELECT DISTINCT (DSF.SOLD_TO_CUSTOMER_KEY) AS CUSTS,
SUM (CASE WHEN DSF.NET_PRICE >=0 THEN NET_PRICE ELSE 0 END ) AS SALES,
SUM (CASE WHEN DSF.NET_PRICE <=0 THEN NET_PRICE ELSE 0 END ) AS DISCOUNT
FROM DAILY_SALES_FACT DSF,
MATERIAL_DIM MD
WHERE
DSF.SALES_DOC_TYPE_SID = '10'
AND DSF.MATERIAL_SID = MD.MATERIAL_SID
AND DSF.NET_PRICE <> 0
AND DSF.TPNM_ACTUAL_START_DATE_KEY BETWEEN '20160101' AND '20160731'
GROUP BY DSF.SOLD_TO_CUSTOMER_KEY
)
WHERE GME.CUST_CODE = STC.CUSTS;
您使用的是什麼RDBMS? –