2

我有一个表名测试,它有三列 id、m_id 和 s_m_id

我正在执行以下查询

select id,test.nextval listagg(m_id || ',' || s_m_id, ';') within group (order by m_id) as merge_ids 
from test t group by id

比我收到错误 ORA - 02287 此处不允许序列号。

4

1 回答 1

5

你试图一口气做太多的事情。为分组创建一个子查询并稍后添加序列号:

select id, test.nextval, merge_ids
from (
    select id, listagg(m_id || ',' || s_m_id, ';') within group (order by m_id) as merge_ids
    from test t
    group by id
)
于 2013-06-18T05:46:41.277 回答