- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望从在 Oracle 中返回多行的查询中返回包含逗号分隔值列表的单行,实质上是将返回的行展平为单行。
在 PostgreSQL 中,这可以使用 array 和 array_to_string 函数来实现,如下所示:
给定表“people”:
id | name
---------
1 | bob
2 | alice
3 | jon
SQL:
select array_to_string(array(select name from people), ',') as names;
将返回:
names
-------------
bob,alice,jon
如何在 Oracle 9i 中获得相同的结果?
谢谢,
马特
最佳答案
Tim Hall 拥有权威收藏 string aggregation techniques in Oracle .
如果您坚持使用 9i,我个人的偏好是定义一个自定义聚合(该页面上有一个 string_agg 的实现)这样您就可以拥有
SELECT string_agg( name )
FROM people
但是您必须定义一个新的 STRING_AGG 函数。如果您需要避免创建新对象,还有其他方法,但在 9i 中它们将比 PostgreSQL 语法更困惑。
关于arrays - 等同于 Oracle 9i 中的 PostgreSQL array()/array_to_string() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4326868/
ARRAY_TO_STRING()适用于字符串数组,但不支持整数数组。 我有一个包含 ID 列表的重复列,我想将其从美国数据集导出到欧盟数据集。到目前为止,我正在使用 bq query --nouse
运行下面的查询后 SELECT ARRAY_TO_STRING( reporteeNames, '|') FROM `appsflow-dev.PersonRe
在选择中,我使用了这样的 array_to_string(示例) array_to_string(array_agg(tag_name),';') tag_names 我得到了结果字符串 "tag1;
我试图在 redshift 中运行带有联合的 array_to_string,但我不断收到以下错误消息: ERROR: Specified types or functions (one per IN
我正在使用 PostgreSQL 9.5。 我在 PL/pgSQL 中创建一个触发器,当对第二个表执行 INSERT 时,它会向表 (synthese_poly) 添加一条记录 (operation_
你好,我正在编写一个 pgsql 函数,在这个函数中,我有一个使用 array_to_string 方法的请求。 AND id NOT IN (array_to_string(excludeA
我正在尝试在 Postgres 查询中组合行并连接两列(名称、vorname)。 这样效果很好: SELECT nummer, array_to_string(array_agg(nam
我在 posts 和 tags 表之间有 2 个 n-n 关系。这是我在 Postgres 中的查询: SELECT t0.*, array_to_string(array_agg(t2.tag),
我试图找到与 PostgreSQL 函数 array 和 array_to_string 等效的 MySQL,并遇到了 this post但要求 oracle9i 这对我没有帮助。我需要用 MySQL
我有一个如下所示的 Arel 语句: vulns.project(vulns[:id], vulns[:cve_id], vulns[:seve
我想知道 MySQL 中是否有 array_agg() 和 array_to_string 的 PostgreSQL 对应物(或任何东西至少接近这个功能)我的研究试图找到与这两个类似的东西,但我没有任
我希望从在 Oracle 中返回多行的查询中返回包含逗号分隔值列表的单行,实质上是将返回的行展平为单行。 在 PostgreSQL 中,这可以使用 array 和 array_to_string 函数
我是一名优秀的程序员,十分优秀!