【发布时间】:2016-01-26 08:44:38
【问题描述】:
我有 select,其中我只想收集一行:listagg(如下面的代码) 必须限制在
- 最多 40 行(因为 varchar 长度有限) 和
-
所有行的总数与
"P1 = 'Y'" (P1 flag can be only Y or null)。
我在两次选择中分别进行了操作,但我希望它既美观又流畅。
不幸的是,这段代码给了我ORA-00937: "not a single-group group function"。有什么建议怎么做吗?
ls_list := '';
select LISTAGG(A || '.' || B||'('||to_char(C)||')',',')
WITHIN GROUP (ORDER BY B) as Segments
,count(*) over (partition by P1) --this count is the problem
into ls_list, ll_total
from xmltable('DBStatus/Body/Segments/Segment' passing gx_status
columns A VARCHAR2(30) path '@A'
,B VARCHAR2(30) path '@B'
,C NUMBER path '@C'
,P1 CHAR(1) path '@P1'
)
where P1 = 'Y'
and
rownum <= 40;
【问题讨论】: