Ora-01791 不是Selected表达式”错误
SELECT DISTINCT t.EVENTID AS PROCEDUREID,t.DESCRIPTION,t.PROCEDUREGROUP,r.REPORTID,CASE WHEN r.FINISHAMOUNT IS NULL THEN 0 ELSE r.FINISHAMOUNT END ,
CASE WHEN r.ALLFINISHAMOUNT IS NULL THEN 0 ELSE r.ALLFINISHAMOUNT END ,
CASE WHEN r.FINISHPERCENT IS NULL THEN 0 ELSE r.FINISHPERCENT END ,r.OID FROM ENG_PROCEDURECONFIGURE1 t LEFT JOIN ENG_REPORTITEM r
ON t.EVENTID=r.PROCEDUREID WHERE r.ACTIVE=1 AND r.REPORTID='0e2ee7e0-9650-11e0-8bb7-1c6f6546f871' ORDER BY t.taxis
报错-------------------------------
查到关于这个ora错误的解释:
如果在ORDER BY中指定多个列,结果将先按照子句中的第一个列排序,然后第二个,依此类推
在SELECT中未出现的列名也可用于ORDER BY 子句中,主要TABLE中有就行,但如果SELECT子句中出现了DISTINCT关键字,则只能用出现过的列名,而且如果SELECT子句中使用了任何运算符,在ORDER BY 子句中必须保持和SELECT子句中表达式完全一致,否则出现ORA-01791 ERROR正解-------------------------------
SELECT DISTINCT t.EVENTID AS PROCEDUREID,t.DESCRIPTION,t.PROCEDUREGROUP,r.REPORTID,CASE WHEN r.FINISHAMOUNT IS NULL THEN 0 ELSE r.FINISHAMOUNT END ,
CASE WHEN r.ALLFINISHAMOUNT IS NULL THEN 0 ELSE r.ALLFINISHAMOUNT END ,
CASE WHEN r.FINISHPERCENT IS NULL THEN 0 ELSE r.FINISHPERCENT END ,r.OID
,t.taxis FROM ENG_PROCEDURECONFIGURE1 t LEFT JOIN ENG_REPORTITEM r ON t.EVENTID=r.PROCEDUREID WHERE r.ACTIVE=1 AND r.REPORTID='0e2ee7e0-9650-11e0-8bb7-1c6f6546f871' ORDER BY t.taxis