gpt4 book ai didi

sql - PostgreSQL 中 LISTAGG(Oracle 数据库)的等价物是什么?

转载 作者:行者123 更新时间:2023-11-29 11:11:09 26 4
gpt4 key购买 nike

我必须用最新的 PostgreSQL 替换 Oracle 驱动程序。 PostgreSQL 不知道函数 LISTAGG。我必须用逗号分隔 concat 值。 Oracle 的函数 LISTAGG 在 PostgreSQL 中的等价物是什么?

最佳答案

PostgreSQL 中的等效函数是 STRING_AGG()

SELECT STRING_AGG (column_name,', ') 
FROM my_table

string_agg : input values concatenated into a string, separated by delimiter

例如,获取所有 agreement_id 的列表,然后在 Apache Ofbiz 17.12.04 中将其表示为字符串

SELECT STRING_AGG(agreement_id, ', ') FROM agreement_item;

-- result
-- "8000, DS-1000-SALES, DS-1000-PURCH, 9000, AGR_SALES"

关于sql - PostgreSQL 中 LISTAGG(Oracle 数据库)的等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29557563/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com