Oracle 10g中的聚合字符串串联 [英] Aggregate String Concatenation in Oracle 10g

查看:69
本文介绍了Oracle 10g中的聚合字符串串联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Oracle 10 g,我的情况与此类似:

I'm using Oracle 10 g, I have a scenario similar to this:

没有名字
------
1罗尼
1詹姆斯
1个Aby
2山姆
2威利
3麦克

No Name
-- -----
1 Rony
1 James
1 Aby
2 Sam
2 Willy
3 Mike

我需要对字符串进行聚合和连接(在它们之间使用单个空格),以获取结果:

I need to aggregate and concatenate the strings (with a single space in between), in a way to get the results:

没有名字
------
1罗尼·詹姆斯·阿比
2山姆·威利
3麦克

No Name
-- -----
1 Rony James Aby
2 Sam Willy
3 Mike

我正在使用Oracle 10g,必须使用SQL而不是PL/SQL来实现.有出路吗?

I'm using Oracle 10g and have to implement this using SQL and not PL/SQL. Is there a way out?

推荐答案

在11G上很容易,您可以使用LISTAGG功能,但在10G上则不然

It is easy on 11G, you can use the LISTAGG function, but sadly not on 10G

这里有一些针对较早版本的技术,但是它们确实需要编写函数.

There are some techniques here for earlier versions however they do require a function to be written.

http://www.oracle-base.com/article/misc/string-aggregation-techniques.php

这篇关于Oracle 10g中的聚合字符串串联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆