Oracle函数--字符串拼接
常用的字符串聚合(拼接)函数介绍
1.WMSYS.WM_CONCAT
从oracle 10G开始支持,使用案例如下:
select deptno,wmsys.wm_concat(ename)
from emp
group by deptno;
若想将字符之间的分隔符换成其他标点,可添加一个replace函数
select deptno,replace(wmsys.wm_concat(ename),',','、')
from emp
group by deptno;
2.LISTAGG(measure_expr,delimiter) WITHIN GROUP(order_by_clause) OVER(query_partition_clause)
从oracle 11G R2开始支持,可以自己指定分隔符,拼接的字符串可以按照某列排序,使用案例如下:
select deptno,Listagg(ename, '、') Within Group (Order by sal)
from emp
group by deptno;
3.SYS_CONNECT_BY_PATH
从oracle 9i开始支持,有2个参数,第一个参数是形成树形式的字段,第二个参数是父级和其子级分隔显示用的分隔符,该函数适用于有父子关系的树形结构显示,使用案例如下:
select MAX(deptno),max(substr(sys_connect_by_path(ename,'-'),2))
from emp
where deptno=10
start with ename='KING'
connect by prior empno=mgr
;
Oracle函数--字符串拼接的更多相关文章
- oracle逗号字符串拼接小工具
oracle逗号字符串拼接小工具 http://www.zui#dai#ma.com/share/1932670249667584.htm 在使用oracle进行数据查询时,常常需要使用到in语句,如 ...
- Codeforces 538 A. Cutting Banner-substr()函数字符串拼接
A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- [转]Oracle字符串拼接的方法
本文转自:http://www.blogjava.net/liuwuping12064915/archive/2011/06/27/353096.html 和其他数据库系统类似,Oracle字符串连接 ...
- WMSYS.WM_CONCAT(distinct(字段名)) 函数,字符串拼接函数。合并列
合并列函数 WMSYS.WM_CONCAT(distinct(字段名)) 函数 可以实现字符串拼接在一起,这种情况可以在要求把一个字段的多个值拼接在一起的时候使用.其中distinct可以去掉重复的值 ...
- mysql 字符串拼接函数CANCAT()与GROUP_CANCAT()
1.CONCAT() 拼接单行字符串 select concat(‘100’,user_id) from table1; select concat('11','22','33'); 结果 11223 ...
- oracle获取字符串长度函数length()和hengthb()
原文:oracle获取字符串长度函数length()和hengthb() lengthb(string)计算string所占的字节长度:返回字符串的长度,单位是字节 length(string)计算s ...
- ||在oracle数据库中起到字符串拼接的作用
例子:select org.id from org where inner_code like '12011601001' || '%' ||在oracle数据库中起到字符串拼接的作用,上面等同于'1 ...
- Oracle截取字符串函数和查找字符串函数,连接运算符||
参考资料:Oracle截取字符串和查找字符串 oracle自定义函数学习和连接运算符(||) oracle 截取字符(substr),检索字符位置(instr) case when then else ...
- sql中保留一位小数的百分比字符串拼接,替换函数,换行符使用
select num ,cast(round(convert(float,isnull((a.Sum_Num-d.Sum_Num),0))/convert(float,c.Sum_Store_Num ...
随机推荐
- Sprint(第一天11.14)
Sprint1第一阶段 1.类名:软件工程-第一阶段 2.时间:11.14-11.23 3.选题内容:点餐系统 4.团队博客地址:http://www.cnblogs.com/iamCarson/ 团 ...
- zookeeper第二课 客户端的简单命令
zookeeper的每个节点既可以是目录也可以是文件,节点上只存一些协调数据(状态.配置.位置),单位一般是KB,大部分数据用sdfs上 只有持久化的节点才可以有子节点,临时节点不可以有自子节点. 客 ...
- Model Binding
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- 19 Using Optimizer Hints
19.1 Overview of Optimizer Hints A hint is an instruction to the optimizer. In a test or development ...
- [css3]CSS3选择器:nth-child和:nth-of-type之间的差异
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1709 一.深呼吸,直 ...
- c c++怎么判断一个字符串中是否含有汉字
c c++怎么判断一个字符串中是否含有汉字 (2013-02-05 10:44:23) 转载▼ #include #include int main() { char sztext[] = ...
- 整理一下以前的Html+css3复习笔记
一.html5新特性 常用语义标签:nav footer header section mark 功能标签 video audio iframe canvas(画布和绘图功能) input新ty ...
- C关键字
1 extern可以置于变量或者函数前,以标示变量或者函数的定义在别的文件中,提示编译器遇到此变量和函数时在其他模块中寻找其定义
- IIS7配置asp网站
An error occurred on the server when processing the URL. Please contact the system administrator. If ...
- UIView及其子类
一.UI概述 UI(User Interface):用户界⾯,用户能看到的各种各样的⻚面元素. iOS App = 各种各样的UI控件 + 业务逻辑和算法 二.UIView 在手机上显示的内容都是UI ...