본문 바로가기

TECH/ORACLE

ORA-01791: not a SELECTed expression | ERROR


이슈 :

SELECT DISTINCT B.SUPCONTNO, 

       A.BUILDNO, 

       A.SUPCONTCG, 

       A.ZZPERNR, 

       A.CONT_DATE, 

       A.EQALL_REQUEST, 

       A.EQALLC_STAT, 

       B.FSSPDATE 

  from SAPR3.ZTSSUPCONT A, SAPR3.ZTSSUPCONTD B 

WHERE A.MANDT = '110' 

   AND A.MANDT = B.MANDT 

   AND A.SUPCONTNO = B.SUPCONTNO 

ORDER BY  B.FSSPDATE  < > B.SUPCONTNO 변경 

SELECT문에서 DISTINCT와 ORDER BY절을 함께 사용할 땐 

ORDER BY 절에는 SELECT문에 사용한 ITEM만을 적을 수 있다. 

(또는 ORDER BY절에서 ITEM을 삭제)

 

ORA-01791 not a SELECTed expression

Cause: 

There is an incorrect ORDER BY item. The query is a SELECT 

DISTINCT query with an ORDER BY clause. In this context, all ORDER BY 

items must be constants, SELECT list expressions, or expressions whose     

operands are constants or SELECT list expressions.

Action: 

Remove the inappropriate ORDER BY item from the SELECT list and 

retry the statement.