У меня есть оператор SELECT, который отлично работает до части CASE, я думаю, что это просто синтаксическая ошибка и бит lead time. Я использую Oracle APEX.

Я получаю ошибку;

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

Спасибо за любую помощь, опасный Брайан

-1
DangerousTreacle 21 Апр 2016 в 21:23

2 ответа

Лучший ответ

Это то, что вы хотите?

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) */
  CASE
    WHEN popayment.datedelivered - purchaseorder.duedate -1 <0
    THEN 'early'
    WHEN popayment.datedelivered - purchaseorder.duedate -1 >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
1
Cristian_I 21 Апр 2016 в 18:33

Вам следует удалить ; в end as "lead time";

1
Pham X. Bach 21 Апр 2016 в 18:26