第4行缺少关键字错误
我正在使用oracle sql
SELECT invoice_num, invoice_item, sales_order_num, sales_order_item, NET_aMT, list_amt, COST_PERCENT,
case when product_type_code='PTO'
THEN 0
ELSE INV_AMT COST_PERCENT over (PARTITION BY sales_order_num, sales_order_item,invoice_num)
END
ALLOC_NET
FROM(
select invoice_num, invoice_item, sales_order_num, sales_order_item, NET_aMT, list_amt,
case when p.product_type_code IN ('PTO','ATO')
then sum(NET_AMT) over (PARTITION BY sales_order_num, sales_order_item, invoice_num)
else 0
end
as INV_AMT,
cost_amt,
case when p.product_type_code = 'ATO'
then SUM(cost_amt) OVER (PARTITION BY sales_order_num, sales_order_item, invoice_num)
else 0
as pto_cost,
case when p.product_type_code = 'ATO'
then (cost_amt/SUM(cost_amt) OVER (PARTITION BY sales_order_num, sales_order_item, invoice_num))
else 0
end as cost_percent,
p.product_type_code
from edw.w_sales_invoice_line_f f, edw.w_product_d p
where f.sales_order_num = '11574425' and f.product_wid = p.row_wid and sales_order_item IN ( '5','1','2','3')
AND invoice_item!=1
);
我得到:
ORA-00905: missing keyword
00905. 00000 - "missing keyword"
*Cause:
*Action:
Error at Line: 4 Column:
我该如何解决?
答案 0 :(得分:0)
此CASE
似乎无效:
case when product_type_code='PTO' THEN 0
ELSE INV_AMT*COST_PERCENT over (PARTITION BY sales_order_num, sales_order_item,invoice_num)
END ALLOC_NET
您似乎认为COST_PERCENT
是解析函数,但是-文档不同意(即,我从未听说过,Google不会返回任何东西)。你能解释一下是什么吗?