1>to_char,将日期转换为字符;add_months,在第一个参数的日期上加或者减第二个参数的值;

select dkzh,jkhtbh,yhkrq,dkffrq,shqs,dqyqcs,to_char(add_months(dkffrq,shqs+dqyqcs+1),'yyyymm') from grdk_dk_zz a where a.dkzt in('02','03') and jgbm like '01'||'%' and to_char(a.yhkrq,'yyyymm')<>to_char(add_months(a.dkffrq,a.shqs+a.dqyqcs+1),'yyyymm');

      2>avg,取平均值;round,保留第二个参数的几位小数,四舍五入;

select jkhtbh, round(avg(fse), 2) fse

               from (select jkhtbh, hkqs, sum(fse) fse

                       from grdk_dk_hkmx

                      where hkqs >=

                            to_char(add_months(sysdate, -3), 'yyyymm')

                        and jgbm like  '01%'

                        and hkzt in ('02', '03', '05')

                      group by jkhtbh, hkqs)

              group by jkhtbh;

     3>lpad函数将左边的字符串填充一些特定的字符其语法格式如下:lpad(string,n,[pad_string])

    v_mm:=lpad(to_char(v_yd1),2,'0');

     4>last_day函数返回一个月最后一天

while v_yhkrq<=(case when v_sf01=0 then v_shrq else last_day(v_shrq) end) and v_dkye>0 and v_shqs<v_dkqs

     5>upper( 字符串),返回字符串的大写

select VIEW_DEFINITION from v$fixed_view_definition where view_name=upper('v$fixed_view_definition');

    6>substr(字符串,数字,数字),截取一段字符串

select kmmc from cw_pz_fl where kmbh like '21905%';

1550910011(1).jpg

select substr(kmmc,14,12) from cw_pz_fl where kmbh like '21905%';

   7>instr(a,b) ,a字符串是否包含b字符串

select f_newid,d.kfsbm,c.jzrq,c.jzrq,a.xmbh,a.jgbm,' ',c.dffse,'期房贷款',0,0,' ',' ',' ',0,' ',0,0,0,' ','01',' ',0,f_hfsc_max_pzbh(a.jgbm,'0302'),' ',0,1,' ',' ',null,0,0,0,0,0,82,3521,'zxb',f_hfsc_max_pzbh(a.jgbm,'0302'),'伍芳',a.jkrxm,a.jkrzjh,a.jkhtbh,' ','伍芳',' '

  from grdk_sq_htxx a,

       (select *

          from cw_pz_fl b

         where b.jzrq between date '2018-01-01' and date

         '2018-12-31'

           and b.kmbh like '21905%'

           and b.jffse = 0) c,

       grdk_sfdw d

 where instr(c.zhaiyao, a.jkrxm) > 0 and a.wtskkhdwmc=d.kfsmc;

  8>trunc    去掉时分秒,保留年月日

          v_hdrq      date:=trunc(sysdate);

  9>nvl(a,0),如果a为空,就取第二个数值零;

       select count(*),nvl(sum(gryjce+dwyjce+bcyjce+czybte),0) into v_hjrs2,v_hjje2 from gjzf_gr_zz

       where  dwzh=v_dwzh and grzhzt='01' and jzny=v_rq ;