SELECT E.EMPNO,E.DEPTNO,E.SAL,E.COMM,
COALESCE(SAL,0)+COALESCE(COMM,0) AS T1,
CASE
WHEN E.DEPTNO=10 THEN COALESCE(E.SAL,0)+COALESCE(E.COMM,0)
WHEN D.DNAME='ACCOUNTING' THEN COALESCE(E.SAL,0)-COALESCE(E.COMM,0)
ELSE 0 END AS T,
sum(T+T1) as T2
FROM EMP E LEFT OUTER JOIN DEPT D ON E.DEPTNO=D.DEPTNO;
得到如下錯誤:如何總結別名列case語句在SQL
ORA-00904: "T1": invalid identifier 00904. 00000 - "%s: invalid identifier" *Cause:
*Action: Error at Line: 7 Column: 7
有可能是區分大小寫的問題。你檢查了嗎? –
爲什麼所有的downvotes?問題很明顯,我們有所有的細節,完整的錯誤信息,完整的背景......該死的野人。 – mathguy