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

编程入门 行业动态 更新时间:2024-10-26 00:24:01
本文介绍了PostgreSQL 中 LISTAGG(Oracle 数据库)的等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我必须用最新的 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 数据库)的等价物是什么?

本文发布于:2023-10-27 03:39:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532203.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:等价物   数据库   PostgreSQL   LISTAGG   Oracle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!