去掉首尾空格

SELECT TRIM('   abc '), ltrim('   abc '), rtrim('   abc ') FROM dual;

去掉首尾的其他字符

SELECT /*TRIM(';a;b;c;'),*/ ltrim(';a;b;c;',';'), rtrim(';a;b;c;',';')  FROM dual;

注意:无法使用TRIM(‘;a;b;c;’, ‘;’)的格式

但是TRIM()却有它自己的格式

SELECT TRIM(';' FROM ';a;b;c;'),

       TRIM(leading ';' FROM ';a;b;c;'),

       TRIM(trailing ';' FROM ';a;b;c;'),

       TRIM(both ';' FROM ';a;b;c;')

  FROM dual;

去掉首尾多个字符

对于去除首尾多个字符的时候,需要特别注意的是,Oracle数据库会从字符串中扫描,移除掉去除集合中出现的每一个字符,直到遇到第一个不在去除集合中的字符为止,而不是去去掉去除集合中的字符串。

SELECT LTRIM('thetomsbthhe', 'the'),RTRIM('thetomsbthhe', 'the') FROM dual;

注意:TRIM(leading 'the' FROM 'thetomsbthhe')是不行的,此函数的截取集仅能包含一个字符。

select * from
(
--租用--
select rownum as 编号,gxrxm as 承租人 ,(case trim(gxrxb ) when '' then '男' when '' then '女' else '不详' end ) as 性别,
rtrim( mobilephone ||','|| LXDH, ',') as 联系方式 , (select (select gxmc from gxxx where t2. gx= gxdm and rownum= 1) from wrxxb t2
where t1.djh=djh and rownum=1 and rq=(select min( rq) from wrxxb where t1. djh= djh)) 关系 ,rq as 办理日期 ,'租用' as 业务类型
--,mwje as 墓价,zmj 成交价,(mwje-zmj) as 优惠金额 ,(SELECT mj FROM mwdmxx WHERE djh=T1.djh) as 面积
from ywdjb t1 where to_char(rq ,'yyyy-mm-dd')>= '2015-07-01' and to_char(rq, 'yyyy-mm-dd')<='2015-07-31' and zxflag= ''
union all
--续租--
select rownum as 编号,t2.gxrxm as 承租人 ,(case trim(t2 .gxrxb ) when '' then '男' when '' then '女' else '不详' end ) as 性别,rtrim( t2.mobilephone|| ','||t2.LXDH,',' ) as 联系方式 ,
(select (select gxmc from gxxx where t3 .gx =gxdm and rownum=1) from wrxxb t3
where t1.djh=djh and rownum=1 and rq=(select min( rq) from wrxxb where t1. djh= djh)) 关系 ,t1.rq as 办理日期 ,t1 .ywmc as 业务类型
from qtywb t1 ,ywdjb t2 where t1 .djh =t2 .djh and to_char(t1. rq, 'yyyy-mm-dd')>='2015-07-01' and
to_char(t1.rq,'yyyy-mm-dd' )<='2015-07-31' and t1 .zxflag ='' and t1.ywmc= '续租'
union all
--合葬--
select rownum as 编号,t2.gxrxm as 承租人 ,(case trim(t2 .gxrxb ) when '' then '男' when '' then '女' else '不详' end ) as 性别,rtrim( t2.mobilephone|| ','||t2.LXDH,',' ) as 联系方式 ,
(select (select gxmc from gxxx where t3 .gx =gxdm and rownum=1) from wrxxb t3
where t1.djh=djh and rownum=1 and rq=(select min( rq) from wrxxb where t1. djh= djh)) 关系 ,t1.rq as 办理日期 ,t1 .ywmc as 业务类型
from qtywb t1 ,ywdjb t2 where t1 .djh =t2 .djh and to_char(t1. rq, 'yyyy-mm-dd')>='2015-07-01' and
to_char(t1.rq,'yyyy-mm-dd' )<='2015-07-31' and t1 .zxflag ='' and t1.ywmc= '合葬'
union all
--老墓改造--
select rownum as 编号,t2.gxrxm as 承租人 ,(case trim(t2 .gxrxb ) when '' then '男' when '' then '女' else '不详' end ) as 性别,rtrim( t2.mobilephone|| ','||t2.LXDH,',' ) as 联系方式 ,
(select (select gxmc from gxxx where t3 .gx =gxdm and rownum=1) from wrxxb t3
where t1.djh=djh and rownum=1 and rq=(select min( rq) from wrxxb where t1. djh= djh)) 关系 ,t1.rq as 办理日期 ,t1 .ywmc as 业务类型
from qtywb t1 ,ywdjb t2 where t1 .djh =t2 .djh and to_char(t1 .rq ,'yyyy-mm-dd')>= '2015-07-01' and
to_char(t1.rq,'yyyy-mm-dd' )<='2015-07-31' and t1 .zxflag ='' and t1.ywmc= '老墓改造'
)
order by 办理日期

用Oracle的TRIM函数去除字符串首尾指定字符的更多相关文章

  1. JavaScript trim 实现去除字符串首尾指定字符的简单方法

    String.prototype.trim = function (char, type) { if (char) { if (type == 'left') { return this.replac ...

  2. JavaScript trim 实现(去除字符串首尾指定字符)

    String.prototype.trim = function (char, type) { if (char) { if (type == 'left') { return this.replac ...

  3. SQL TRIM()函数去除字符串头尾空格

    SQL TRIM()函数去除字符串头尾空格 SQL 中的 TRIM 函数是用来移除掉一个字串中的字头或字尾.最常见的用途是移除字首或字尾的空白.这个函数在不同的资料库中有不同的名称: MySQL: T ...

  4. trim()方法去除字符串首尾空格

    trim()方法去除字符串首尾空格 1.原生js                 Function trimStr(str){                         Return str.r ...

  5. 【iOS】去除字符串首尾空格或某字符

    在iOS的实际开发中,常会出现需要去除空格的情况,总结有三种情况: 去除字符串首尾连续字符(如空格): 去除字符串首部连续字符(如空格): 去除字符串尾部连续字符(如空格): 去除字符串首尾连续字符( ...

  6. 利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法

    1.利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法 首先判断字符串的长度是否为0,如果是,直接返回字符串 第二,循环判断字符串的首部是否有空格,如 ...

  7. python练习题:利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法

    方法一: # -*- coding: utf-8 -*- # 利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法: def trim(s): whil ...

  8. 【Python实践-4】切片操作去除字符串首尾的空格

    #利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法 def trim(s): while s[0:1]==' ': s=s[1:] while s[ ...

  9. [py]str list切片-去除字符串首尾空格-递归思想

    取出arr的前几项 #方法1 print([arr[0], arr[1]]) #方法2 arr2 = [] for i in range(2): arr2.append(arr[i]) print(a ...

随机推荐

  1. Python3 错误处理 和 测试

    try 让我们用一个例子来看看try的机制: try: print('try...') r = 10 / 0 except ZeroDivisionError as e: print('except: ...

  2. php中utf8 与utf-8 与utf8 无BOM

    utf8 与utf-8 相信很多程序员刚开始也会有这样的疑惑,如题,我也是.    其实,他们可以这样来区分.    一.在php和html中设置编码,请尽量统一写成“UTF-8”,这才是标准写法,而 ...

  3. Delphi IDE下载全地址

    Delphi IDE下载全地址: http://pan.baidu.com/share/home?uk=1060104307#category/type=0 还是网友伟大呀.当然有钱的公司还是应该多多 ...

  4. 【小知识】DataTable 转 List -----------点滴之水,汇涓涓细流,成汪洋大海

    在大部分时候我们从ADO中得到的数据都是DataTable.DataSet数据源,然而有强迫症的同学老是喜欢折腾,硬是要把它转换为实体集合,说是DataTable效率差云云,于是乎收到了同化. 必要信 ...

  5. python模块之os和os.path模块

    1.os模块os.listdir(dirname) 列出dirname下的目录和文件os.getcwd()函数得到当前工作目录,即当前Python脚本工作的目录路径.os.getenv()和os.pu ...

  6. C# - Delegate Simple Demo

  7. npm常用命令解析

    npm是什么 NPM的全称是Node Package Manager,是随同NodeJS一起安装的包管理和分发工具,它很方便让JavaScript开发者下载.安装.上传以及管理已经安装的包. npm ...

  8. python @property 属性

    在绑定属性时,如果我们直接把属性暴露出去,显然不合适,是通过getter和setter方法来实现的,还可以定义只读属性,只定义getter方法,不定义setter方法就是一个只读属性: class P ...

  9. Matlab 文件命名规则

    Matlab 文件命名规则 1.文件名命名要用英文字符,第一个字符不能是数字和下划线. 2.文件名不要取为matlab的一个固有函数,m文件名的命名尽量不要是简单的英文单词,最好是由大小写英文.数字. ...

  10. sqlserver删除重复数据

    select identity(int,1,1) as autoID, * into #Tmp from [QYTS_QiYeCecdb]select min(autoID) as autoID in ...