select ename,sal,avg_sal from emp join
(select deptno,avg(sal) avg_sal from emp group by deptno) t
on emp.deptno = t.deptno;
报错ora-00911
------解决方法--------------------------------------------------------
------解决方法--------------------------------------------------------
原样复制,没有错,难道是有不可见的字符?
你用记事本另存一下,指定编码为ansi试试
SQL> select ename,sal,avg_sal from emp join 2 (select deptno,avg(sal) avg_sal from emp group by deptno) t 3 on emp.deptno = t.deptno; ENAME SAL AVG_SAL---------- ---------- ----------SMITH 800 2175ALLEN 1600 1566.66667WARD 1250 1566.66667JONES 2975 2175MARTIN 1250 1566.66667BLAKE 2850 1566.66667CLARK 2450 2916.66667SCOTT 3000 2175KING 5000 2916.66667TURNER 1500 1566.66667ADAMS 1100 2175ENAME SAL AVG_SAL---------- ---------- ----------JAMES 950 1566.66667FORD 3000 2175MILLER 1300 2916.6666714 rows selected.
------解决方法--------------------------------------------------------
应该是分号的问题把。。