我有一個SELECT
語句,它工作正常,直到CASE
部分,我認爲這只是一個語法錯誤和lead time
位。我正在使用Oracle APEX。計算列中的CASE語句問題
我得到錯誤;
ORA-00923: FROM keyword not found where expected
select
supplier.companyname as "Supplier",
purchaseorder.orderdate as "Order Date",
purchaseorder.duedate as "Due Date",
popayment.datedelivered as "Delivered",
(popayment.paymentdate - popayment.datedelivered) - 31 as paidontime,
/* this is the same as the next one (this works fine) */
(popayment.datedelivered - purchaseorder.duedate) - 1 as deleiverylate,
/* trying to advance the previous query (this does not work) */
popayment.datedelivered - purchaseorder.duedate -1,
case when "lead time" <0 then 'early'
when "lead time" >0 then 'late'
else 'on time'
end as "lead time";
from supplier, purchaseorder, suppliercontact, popayment
where
purchaseorder.SUPPLIERCONTACTID2 = suppliercontact.suppliercontactid
and
supplier.supplierid = suppliercontact.supplierid
and
purchaseorder.purchaseorderid = popayment.purchaseorderid
order by COMPANYNAME
感謝所有幫助 危險布賴恩
爲什麼在「提前期」之後有分號?那不應該在那裏。 (並且與錯誤無關,但爲什麼不使用ANSI風格的聯接呢?) –
@DangerousTreacle能否在'lead time'<0'的情況下解釋字段'lead time'? –