LISTAGG在Oracle Cloud中不起作用

时间:2017-04-28 17:13:01

标签: oracle oracle11g oracle-bi

我正在尝试运行下面的查询

select organization_id
  , listagg(secondary_inventory_name, ',') within group(order by secondary_inventory_name) as the_list
from inv_secondary_inventories
group by organization_id

,但它一直给出这个错误:

oracle.xdo.servlet.data.DataException: oracle.xdo.XDOException: java.sql.SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expected

我做错了什么?

1 个答案:

答案 0 :(得分:-1)

select organization_id
  , listagg(secondary_inventory_name, ',') within group(order by secondary_inventory_name) as the_list
from inv_secondary_inventories
group by organization_id

以上是您的查询。只需将listagg语句放在方括号中,这将起到神奇的作用。

select organization_id
  ,( listagg(secondary_inventory_name, ',') within group(order by secondary_inventory_name) )as the_list
from inv_secondary_inventories
group by organization_id