去掉首尾空格

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. JS访问Struts 2 ValueStack中的内容

    /* * var myArray = new Array("${vacant[0]}", "${vacant[1]}", "${vacant[2]}& ...

  2. VS2013中Django流水账笔记--配置环境

    一.开发环境 Win7 64位搭建开发环境.需要准备VS2013.Python34.PTVS2013. 1.http://pytools.codeplex.com/ 下载工具,下载之后进行安装即可,我 ...

  3. 关于解决JQuery发送Ajax请求后,IE缓存数据不更新的问题

    http://www.cnblogs.com/lys_013/archive/2013/08/07/3243435.html 今天在做ajax页面无刷新请求后台服务器数据的时候,IE下遭遇Ajax缓存 ...

  4. 51nod贪心算法入门-----任务分配问题

    任务执行顺序 有N个任务需要执行,第i个任务计算时占R[i]个空间,而后会释放一部分,最后储存计算结果需要占据O[i]个空间(O[i] < R[i]). 分析: 可以抽象成,从一个整数开始,每次 ...

  5. Visual C++ 对话框增加菜单栏

    1.添加菜单资源     在resourceview视图中右击选择insert,添加一个菜单资源IDR_MENU1,同时设定好响应的菜单项,例 如:         菜单1               ...

  6. python 内建函数 str() 和 repr() 的区别

    1.内建函数str()和repr() 或反引号操作符(``)可以方便地以字符串的方式获取对象的内容.类型.数值属性等信息. 2.str()函数得到的字符串可读性好(故被print调用) 3.repr( ...

  7. mysql之——存储过程 + 游标 + 事务

    下面是自己曾经编写过的mysql数据库存储过程,留作存档,以后用到的时候拿来参考. 其中,涉及到了存储过程.游标(双层循环).事务. [说明]:代码中的注释只针对当时业务而言,无须理会. 代码如下: ...

  8. 关于size_t与size_type

    整理自关于size_t与size_type 问题起源于这样一段代码: #include <algorithm> #include <stdio.h> int main() { ...

  9. Python PIL库之Image注解(API)

    http://blog.csdn.net/xiezhiyong3621/article/details/8499543 class Image Methods defined here: __geta ...

  10. 汇编语言中,SP,BP ,SI,DI作用?

    这个很简单: sp:表示栈顶指针,指向栈顶地址.与SS相配合使用.ss为栈段. bp:是基址指针,段地址默认在SS中.可以定位物理地址,比如:"mov ax,[bp+si+6]/mov ax ...