10.1.0.4.2的数据库
SQL*Plus: Release 10.1.0.4.2 - Production on 星期四 8月 8 10:18:59 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.表如下:
create table t_lyh(
    c1 number,
    c2 varchar2(20)
);
表数据:
        C1 C2
---------- --------------------
         1 a
         1 b
         1 c
         2 x
         2 y
         3 z
用apps用户登录数据库,         
select a.c1, wmsys.wm_concat(a.c2) new_result from t_lyh a group by a.c1
却报错:"WMSYS","WM_CONCAT":invalid identifier将函数赋wm_concat权限给用户apps,却赋不了
grant select ON wm_concat to apps
报错:table or view does not exist
不是说10g以上的就有wm_concat吗,怎么会提示没有表或视图哪位帮忙看看

解决方案 »

  1.   

    这是要行列转换啊
    把sysdba权限给apps试试
      

  2.   

     SELECT c1, SUBSTR(MAX (SYS_CONNECT_BY_PATH (c2, ',')), 2) new_result
     FROM (
      SELECT c1, c2, rn, LEAD (rn) OVER (PARTITION BY c1 ORDER BY rn) rn1
      FROM (SELECT c1, c2, ROW_NUMBER () OVER (ORDER BY c2) rn
       FROM t_lyh )
     )
     START WITH rn1 IS NULL
     CONNECT BY rn1 = PRIOR rn
     GROUP BY c1;