ORA-00905 SQL错误

时间:2014-07-23 15:40:30

标签: sql oracle

错误突出显示问题是在主查询的WHERE子句前面。我不确定我缺少什么,我们将非常感谢任何帮助。

SELECT /*+ use_hash (doi,seg,v) */
doi.ORDER_ID AS "PO"
, doi.DISTRIBUTOR_ID AS "Vendor ID"
, doi.ISBN AS "ASIN"
, doi.QUANTITY_ORDERED AS "Quantity Confirmed"
, v.VENDOR_NAME AS "Vendor"
FROM D_DISTRIBUTOR_ORDER_ITEMS doi
LEFT JOIN VENDORS v
JOIN    (SELECT /*+ use_hash */
    psm.ASIN
    FROM PRODUCT_SEGMENT_MEMBERSHIP psm
    WHERE psm.SEGMENT_ID = 784885) seg
ON doi.ISBN = seg.ASIN
AND doi.DISTRIBUTOR_ID = v.VENDOR_ID
WHERE doi.ORDER_DAY LIKE 2009/04/06
ORDER BY seg.ASINSIN

2 个答案:

答案 0 :(得分:2)

替换

WHERE doi.ORDER_DAY LIKE 2009/04/06

通过

WHERE doi.ORDER_DAY LIKE '2009/04/06'

答案 1 :(得分:0)

您需要将连接条件doi.DISTRIBUTOR_ID = v.VENDOR_ID从where子句移动到from子句和 具体在LEFT JOIN VENDORS v之后如下:

SELECT
  /*+ use_hash (doi,seg,v) */
  doi.order_id         AS "PO" ,
  doi.distributor_id   AS "Vendor ID" ,
  doi.isbn             AS "ASIN" ,
  doi.quantity_ordered AS "Quantity Confirmed" ,
  v.vendor_name        AS "Vendor"
FROM d_distributor_order_items doi
LEFT JOIN vendors v
ON doi.distributor_id = v.vendor_id
JOIN
  (SELECT
    /*+ use_hash */
    psm.asin
  FROM product_segment_membership psm
  WHERE psm.segment_id = 784885
  ) seg
ON doi.isbn                = seg.asin
WHERE trunc(doi.order_day) = '2009/04/06'
ORDER BY seg.asinsin

我修饰并假设你想截断日期而不是使用类似条件(没有意义)。