ORACLE SQL listagg 函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5569633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORACLE SQL listagg function
提问by Micharch54
I'm not sure what's going on here, mostly because I've never used this function, but when I use the listagg function on our Oracle 11g database it gives me an ORA-00923 FROM keyword not found where expected.
我不确定这里发生了什么,主要是因为我从未使用过这个函数,但是当我在我们的 Oracle 11g 数据库上使用 listagg 函数时,它给了我一个 ORA-00923 FROM 关键字,在预期的地方找不到。
Here's my SQL
这是我的 SQL
SELECT cdm.courses_id,cde.additional_resources, listagg (dm.delivery_method_desc, ',')
WITHIN GROUP (ORDER BY dm.delivery_method_desc) delivery_methods
FROM tablespace.course_de_delivery_methods cdm,
tablespace.course_distance_ed cde,
tablespace.delivery_methods dm
WHERE cdm.courses_id = cde.courses_id
AND cdm.delivery_methods_id = dm.delivery_methods_id
GROUP BY cdm.courses_id
I haven't a clue why this is breaking. I was following the example found here.
回答by Justin Cave
Are you using 11.1 or 11.2? LISTAGG was introduced in 11.2, it was not available in 11.1.
您使用的是 11.1 还是 11.2?LISTAGG 是在 11.2 中引入的,它在 11.1 中不可用。
Your SQL statement looks valid to me in 11.2. But you'd get an error in 11.1 and ORA-00923 would seem like a reasonable error in 11.1.
你的 SQL 语句在 11.2 中对我来说是有效的。但是你会在 11.1 中得到一个错误,而 ORA-00923 在 11.1 中似乎是一个合理的错误。