• 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

    *

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


  • 相关阅读:
    LNMP搭建随笔
    MySQL中concat函数(连接字符串)
    解决bash: mysql: command not found 的方法
    linux下导入、导出mysql数据库命令
    MysqL的root用户不允许远程连接,只能通过PHPMYADMIN
    CentOS7安装iptables防火墙
    为Linux服务器设置静态IP的方法
    linux下mysql的root密码忘记解决方法
    tcp的三次握手和四次挥手转自https://www.jianshu.com/p/d3725391af59
    go if for while 的使用
  • 原文地址:https://www.cnblogs.com/qingmaple/p/4203587.html
Copyright © 2020-2023  润新知