Sql oracle LISTAGG将多行结果分组为一行无效。ORA-00909

Sql oracle LISTAGG将多行结果分组为一行无效。ORA-00909,sql,oracle,aggregate,Sql,Oracle,Aggregate,我在这里看到一篇文章,它使用Listag将多行分组到一列下的一行中,我查看了文章示例和oracle网站,但我无法让查询正常工作 在sql developer中,错误为ORA-00909:参数数无效 我有以下疑问 select d.id, d.name, d.date_sale, d.address, d.city, d.state, d.zipcode, d.description, d.explanation, d.received_date, listagg(dd.my_id

我在这里看到一篇文章,它使用Listag将多行分组到一列下的一行中,我查看了文章示例和oracle网站,但我无法让查询正常工作

在sql developer中,错误为ORA-00909:参数数无效

我有以下疑问

select d.id, d.name, d.date_sale, d.address, d.city, d.state, d.zipcode, d.description, d.explanation, d.received_date, 
       listagg(dd.my_id, dd.customer_name, dd.category, dd.transaction_date, ';' 
       ) within group (order by dd.transaction_date)
from table1 d
left join table2 dd on d.id = dd.my_id
where d.id =1 and d.isActive =1

非常感谢您的帮助。

将这些值连接在一起,并添加一个
分组:

select d.id, d.name, d.date_sale, d.address, 
       listagg(dd.my_id || dd.customer_name || dd.category, dd.transaction_date, ';' 
              ) within group (order by dd.transaction_date)
from table1 d left join
     table2 dd
     on d.id = dd.my_id
where d.id =1 and d.isActive = 1
group by d.id, d.name, d.date_sale, d.address;

您好,Gordon,我通过您的示例实现了这一点,但我的第一个选择下大约有40个字段,我是否将所有40个字段都添加到“分组依据”中?Thanks@user1250264 . . . 或者使用子查询。不过,这将是一个不同的问题。