问答详情
源自:2-4 使用分组函数2

格式问题,和老师一样的设置,我的查询结果不一样

SQL> select deptno ,wm_concat(ename)from emp group by deptno;

    DEPTNO
----------
WM_CONCAT(ENAME)
--------------------------------------------------------------------------------
        10
CLARK,MILLER,KING

        20
SMITH,FORD,ADAMS,SCOTT,JONES

        30
ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD


SQL> ed
已写入 file afiedt.buf

  1* select deptno 部门号 ,wm_concat(ename) 部门中员工的姓名from emp group by deptno
SQL> /
select deptno 部门号 ,wm_concat(ename) 部门中员工的姓名from emp group by deptno
                                                            *
第 1 行出现错误:
ORA-00923: 未找到要求的 FROM 关键字


SQL>
SQL> ed
已写入 file afiedt.buf

  1* select deptno 部门号 ,wm_concat(ename) 部门中员工的姓名from emp group by deptno
SQL> select deptno ,wm_concat(ename)from emp group by deptno;

    DEPTNO
----------
WM_CONCAT(ENAME)
--------------------------------------------------------------------------------
        10
CLARK,MILLER,KING

        20
SMITH,FORD,ADAMS,SCOTT,JONES

        30
ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD


SQL> ed
已写入 file afiedt.buf

  1* select deptno部门号 ,wm_concat(ename)部门中员工的姓名 from emp group by deptno
SQL> /
select deptno部门号 ,wm_concat(ename)部门中员工的姓名 from emp group by deptno
       *
第 1 行出现错误:
ORA-00904: "DEPTNO部门号": 标识符无效


SQL> select deptno ,wm_concat(ename)from emp group by deptno;

    DEPTNO
----------
WM_CONCAT(ENAME)
--------------------------------------------------------------------------------
        10
CLARK,MILLER,KING

        20
SMITH,FORD,ADAMS,SCOTT,JONES

        30
ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD


SQL> ed
已写入 file afiedt.buf

  1* select deptno 部门号,wm_concat(ename) 部门中员工的姓名 from emp group by deptno
SQL> /

    部门号
----------
部门中员工的姓名
--------------------------------------------------------------------------------
        10
CLARK,MILLER,KING

        20
SMITH,FORD,ADAMS,SCOTT,JONES

        30
ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD


SQL> set linesize 200
SQL> col 部门中员工的姓名 for a60
SQL> select deptno 部门号,wm_concat(ename) 部门中的员工姓名 from emp group by deptno;

    部门号
----------
部门中的员工姓名
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------

        10
CLARK,MILLER,KING

        20
SMITH,FORD,ADAMS,SCOTT,JONES

        30
ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD


SQL>


提问者:菲小白 2017-08-16 20:48

个回答

  • 菲小白
    2017-08-16 20:53:00

    最后的格式