去掉首尾空格

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. thinkcmf thinkphp隐藏后台地址

    做了一个项目,上线的时候 需要隐藏掉domain.com/admin 这个后台地址,但是用的thinkcmf已经预定义好了admin模块. 我们可以用thinkphp自带的模块映射功能实现, 比方说我 ...

  2. 简单的JQuery分页代码

    1. [代码][JavaScript]代码      001 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ...

  3. Oracle procedure存储过程/function函数

    --函数的创建 create function func1(dno number) return NUMBER--必须带有返回值 is v_max number;--定义返回值 begin selec ...

  4. C# 读取快捷方式指向的文件

    C# 读取快捷方式指向的文件 [Flags()] public enum SLR_FLAGS { SLR_NO_UI = 0x1, SLR_ANY_MATCH = 0x2, SLR_UPDATE = ...

  5. MEF学习笔记

    之前公司里用到了一个叫MEF的东西,说来惭愧一直只管写代码却不曾理解MEF框架为何物,今天就来学习一下,这是一篇迟到了不知多久的博客. -------------------------------- ...

  6. Sublime Text 3 配置浏览器预览路径 localhost

    原文链接:http://jingyan.baidu.com/article/15622f2419ce79fdfcbea5ea.html 按步骤设置成功!感谢大侠! 以下是原文: Sublime Tex ...

  7. 【Error listenerStart】 Error listenerStart Context [] startup failed due to previous errors

    发给 报错信息 八月 12, 2015 11:58:19 上午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandle ...

  8. SLua

    安装 1.下载最新版,将Assets目录里的所有内容复制到工程中,对于最终产品,可以删除例子,文档等内容,如果是开发阶段则无所谓. 2.等待unity编译完毕,如果一切顺利的话,将出现SLua菜单,点 ...

  9. ssh中使用set的地方及ref

    22:30 2014/5/2 1.层与层间的set:  xml方式:在action中曾有service的set方法,service层要有dao的service的set方法,dao曾要有hibernat ...

  10. IOS开发—IOS 8 中设置applicationIconBadgeNumber和消息推送

    摘要 在IOS7中设置applicationIconBadgeNumber不会有什么问题,但是直接在IOS8中设置applicationIconBadgeNumber会报错 因为在IOS8中要想设置a ...