PostgreSQL 中 LISTAGG(Oracle 数据库)的等价物是什么? [英] What's the equivalent for LISTAGG (Oracle database) in PostgreSQL?
问题描述
我必须用最新的 PostgreSQL 替换 Oracle 驱动程序.PostgreSQL 不知道函数 LISTAGG.我必须用逗号分隔 concat
值.PostgreSQL 中 Oracle 函数 LISTAGG
的等效项是什么?
PostgreSQL 中的等价函数是 STRING_AGG()
SELECT STRING_AGG (column_name,', ')从 my_table
<块引用>
string_agg:输入值连接成一个字符串,由分隔符分隔
例如,在 Apache Ofbiz 17.12.04 中,获取所有 agreement_id
的列表,然后用字符串表示它
SELECT STRING_AGG(agreement_id, ', ') FROM agreement_item;- 结果-- 8000, DS-1000-SALES, DS-1000-PURCH, 9000, AGR_SALES"
I have to replace the Oracle driver with the newest PostgreSQL. PostgreSQL doesn't know the function LISTAGG. I have to concat
values by comma separated. What's the equivalent for the Oracle's function LISTAGG
in PostgreSQL?
The equivalent function in PostgreSQL is STRING_AGG()
SELECT STRING_AGG (column_name,', ')
FROM my_table
string_agg : input values concatenated into a string, separated by delimiter
For example, get list of all agreement_id
then represent it in a string, in Apache Ofbiz 17.12.04
SELECT STRING_AGG(agreement_id, ', ') FROM agreement_item;
-- result
-- "8000, DS-1000-SALES, DS-1000-PURCH, 9000, AGR_SALES"
这篇关于PostgreSQL 中 LISTAGG(Oracle 数据库)的等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!