Skip to content
Advertisement

ORA-01417: a table may be outer joined to at most one other table

I have this query below for oracle sql:

SELECT
  /*+parallel(4)*/
  TO_CHAR (a.Po_Distribution_Id)           AS INTEGRATION_ID,
  MIN(c.NEED_BY_DATE)                      AS X_ORIG_NEED_BY_DT,
  b.PROMISED_DATE                          AS X_PROMISED_DT,
  MIN(c.PROMISED_DATE)                     AS X_ORIG_PROMISED_DT,
  COALESCE(b.PROMISED_DATE,b.NEED_BY_DATE) AS X_NEED_BY_DT 
      FROM PO_DISTRIBUTIONS_ALL a
LEFT OUTER JOIN PO_LINE_LOCATIONS_ALL b
ON a.LINE_LOCATION_ID=b.LINE_LOCATION_ID
LEFT OUTER JOIN PO_LINE_LOCATIONS_ARCHIVE_ALL c
ON c.LINE_LOCATION_ID=b.LINE_LOCATION_ID
 AND a.CREATION_DATE >= '30-SEP-2017'
and rownum = 10
GROUP BY a.Po_Distribution_Id,
      b.PROMISED_DATE,
      b.PROMISED_DATE,
      b.NEED_BY_DATE

When i execute it, i got ORA-01417: a table may be outer joined to at most one other table. Need help for this error.

Advertisement

Answer

Please use below query. In the current query, your aggregation is incorrect, you have to use same function as you use in the select query. And changed the filter criteria to WHERE instead of AND. Also not sure why you are selecting rownum=10,it will provide you only one record. Is that fine?

SELECT
  /*+parallel(4)*/
  TO_CHAR (a.Po_Distribution_Id)           AS INTEGRATION_ID,
  MIN(c.NEED_BY_DATE)                      AS X_ORIG_NEED_BY_DT,
  b.PROMISED_DATE                          AS X_PROMISED_DT,
  MIN(c.PROMISED_DATE)                     AS X_ORIG_PROMISED_DT,
  COALESCE(b.PROMISED_DATE,b.NEED_BY_DATE) AS X_NEED_BY_DT 
      FROM PO_DISTRIBUTIONS_ALL a
LEFT OUTER JOIN PO_LINE_LOCATIONS_ALL b
ON a.LINE_LOCATION_ID=b.LINE_LOCATION_ID
LEFT OUTER JOIN PO_LINE_LOCATIONS_ARCHIVE_ALL c
ON c.LINE_LOCATION_ID=b.LINE_LOCATION_ID
 WHERE a.CREATION_DATE >= '30-SEP-2017'
and rownum = 10
GROUP BY TO_CHAR (a.Po_Distribution_Id),
         b.PROMISED_DATE
         COALESCE(b.PROMISED_DATE,b.NEED_BY_DATE);
 
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement