oracle对字符串的操作

*

select substr(replace('2014-10-12','-',''),1,6) from dual;     ----201410

<td>

<s:if test="#group[6]>0 ">
<s:if test="(#group[6]*100).toString().length()>=5">
<s:property value="(#group[6]*100).toString().substring(0,5)"/>%

</s:if>
<s:else>
<s:property value="(#group[6]*100).toString()"/>%
</s:else>
</s:if>
<s:else>
${group[6] }
</s:else>

</td>

********trunc(g.kb_bill,4)这是sql语句中,也可以不写

oracle  一个字符串是否包含另一个字符串

select * from a where instr(a,b)>0;用于实现B字段是A字段中的某一部分的时候,要论顺序或者要相邻的字符。

--9
select count(*) from t_zd_khxs a,t_zd_cjjh b
where instr(b.xsimei,a.xsimei)>0 

--323595
select count(*) from t_zd_khxs a,t_zd_cjjh b
where instr(b.xsimei,a.xsimei)=0 
--0
select a.xsimei from t_zd_khxs a,t_zd_cjjh b where instr(b.xsimei,a.xsimei)<=0 
--323604
select count(*) from t_zd_khxs a,t_zd_cjjh b

--select substr('abcsd',0,2) from dual   --ab

 select
 '2014'||monday.the_week,decode(sign(monday.the_day-sunday.the_day),-1,monday.the_day,monday.the_day-6)
 sunday,sunday.the_day sunday from
 (select to_char(wwm,'WW') the_week,to_char(wwm,'D') the_daynum,wwm the_day from (select
 trunc(to_date('2014-01-01','yyyy-mm-dd'), 'MM')+rownum-1 as wwm from user_objects where rownum < 366) where
 to_char(wwm,'D')=1 ) monday,
 (select to_char(wwm,'WW') the_week,to_char(wwm,'D') the_daynum,wwm+1 the_day  from (select
 trunc(to_date('2014-01-01','yyyy-mm-dd'), 'MM')+rownum-1 as wwm from user_objects where rownum < 366) where
 to_char(wwm,'D')=7 ) sunday
 where monday.the_week=sunday.the_week

      本周开始    本周结束

201401   2013/12/30     2014/1/5
201402 2014/1/6 2014/1/12
201403 2014/1/13 2014/1/19
201404 2014/1/20 2014/1/26
201405 2014/1/27 2014/2/2
201406 2014/2/3 2014/2/9
201407 2014/2/10 2014/2/16
201408 2014/2/17 2014/2/23
201409 2014/2/24 2014/3/2

 select
 '2014'||monday.the_week,
 
 decode(sign(monday.the_day-sunday.the_day),-1,monday.the_day,monday.the_day-6) mondy,
  
 sunday.the_day sunday from
 
 (select to_char(wwm,'WW') the_week,to_char(wwm,'D') the_daynum,wwm the_day  
 from (select trunc(to_date('2014-01-01','yyyy-mm-dd'), 'MM')+rownum-1 as wwm from user_objects where rownum < 366) 
 where to_char(wwm,'D')=1 ) monday,
 
 (select to_char(wwm,'WW') the_week,to_char(wwm,'D') the_daynum, wwm+1 the_day  
 from (select trunc(to_date('2014-01-01','yyyy-mm-dd'), 'MM')+rownum-1 as wwm from user_objects where rownum < 366) 
 where to_char(wwm,'D')=7 ) sunday
 
 where monday.the_week=sunday.the_week
 select * from 
 
 (select to_char(wwm,'WW') the_week,to_char(wwm,'D') the_daynum, wwm+1 the_day,wwm
 from (select trunc(to_date('2014-01-01','yyyy-mm-dd'), 'yyyy')+rownum as wwm from user_objects) 
 where to_char(wwm,'D')=7 ) sunday
 
 where the_week=to_char(to_date('2015-01-05','yyyy/mm/dd'),'WW')
 and to_char(wwm,'yyyy')=to_char(to_date('2015-01-05','yyyy/mm/dd'),'yyyy')
 
 
 
-- select * from user_objects

*

有问题在公众号【清汤袭人】找我,时常冒出各种傻问题,然一通百通,其乐无穷,一起探讨


原文地址:https://www.cnblogs.com/qingmaple/p/4203587.html