我有一個選擇查詢,以獲得一個結果集,我的查詢如下:有Select查詢聯接條件錯誤
SELECT T0."REFID", T0."REFID_NR", T0."ID_POS",
CASE
WHEN T4."REFID" IS NOT NULL
THEN T4."REFID"
END AS "result"
FROM "SYSTEM"."T00_SOFT" T0
LEFT OUTER JOIN
(
SELECT T1."REFID", T1."REFID_NR", T1."ID_POS",T1."ARTIKEL" ,T2."VEHW", T2."VNHW" ,
(((T2."VEHW"*100)/(T2."VNHW"))*((T1."ER_AW"*100)))/(T1."BAS_AW") AS "claims"
FROM "SYSTEM"."T00_SOFT" T1
INNER JOIN "SYSTEM"."T00_EG" T2
ON T1."REFID" = T2."REFID"
AND T1."ORGID_WE" = T2."ORGID"
AND T1."ARTIKEL" = T2."MATNR") T4;
當我執行查詢,我得到了以下錯誤:
Could not execute 'SELECT T0."REFID", T0."REFID_NR", T0."ID_POS", CASE WHEN T4."REFID" IS NOT NULL THEN ...' in 42 ms 382 µs .
SAP DBTech JDBC: [257] (at 521): sql syntax error: line 15 col 33 (at pos 521)
這裏第15行是指最後一行,表示錯誤存在於T4
。我沒有發現任何遺漏。如果有人可以建議什麼是gthe問題?
感謝
在THEN語句中,你需要一些字段名稱在T4後面,你可以在那裏引用一個別名... – Sparky
@Sparky你的意思是這樣的嗎?如果是這樣,它仍然不能解決問題。 –
@Strawberry能否請你用蹩腳的詞語來解釋,以便更好地理解? –