去掉首尾空格

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. Linux初始root密码设置

    刚安装好的Linux系统是没有设置root用户密码的,下边介绍如何设置root用户的密码 第一步:sudo passwd 第二步:输入密码 第三步:确认密码 这样三个步骤过后root用户的密码就设置好 ...

  2. Web前端新人笔记之CSS字体

    本章内容是阅读CSS权威指南的一个小积累和随笔.新人必看,老鸟也可查看并指出不足指出以便后人阅读更好地理解.O(∩_∩)O谢谢!!!设置字体属性时样式变的最常见的用途之一:不过,尽管字体选择很重要,但 ...

  3. svn 相关

    // svn相关内容,windows下的可以根据网上的,安装客户端和服务器端安装成功后,可以在服务器端中的 Repositories中建立相关的项目库文件夹,右键相应的文件夹可以复制相关的 url,一 ...

  4. DataGridView添加另外一个控件。

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...

  5. C# DllImport的用法

    大家在实际工作学习C#的时候,可能会问:为什么我们要为一些已经存在的功能(比如Windows中的一些功能,C++中已经编写好的一些方法)要重新编写代码,C#有没有方法可以直接都用这些原本已经存在的功能 ...

  6. Git问题:Cannot update paths and switch to branch 'dev' at the same time.

    使用命令 $ git checkout -b develop origin/develop 签出远程分支,出现以下错误: fatal: Cannot update paths and switch t ...

  7. c/c++中的各种字符串转换

    一:CString 和 *char 的转换: 1:CString -> *char 1)CString转化为*char可以使用CString中的GetBuffer()函数,具体如下: CStri ...

  8. 《C和指针》读书笔记——第一章 快速上手

    1.注释代码可以用: #if 0 statements #endif 2.参数被声明为const,表明函数将不会修改函数调用者的所传递的这个参数. 3.scanf("%d",&am ...

  9. Python 强大而易用的文件操作(转载)

    在Python中可以很方便地做一些诸如浏览目录,创建文件夹,删除文件夹等等的操作. 对文件系统的访问大多通过os模块来实现,因为Python是多平台的,os模块只是前端,具体的实现还是由具体的系统来完 ...

  10. linux awk命令学习

    . awk的运行过程 ) awk_script的组成: ① awk_script可以由一条或多条awk_cmd组成,两条awk_cmd之间一般以NEWLINE分隔 ② awk_cmd由两部分组成: a ...