select regexp_substr('ed2wcsid_ph_20110324.txt','[0-9]+',5) from dual
結果:20110324
select regexp_substr('edwcsid_ph_20110324.txt','[0-9]+') from dual
結果:20110324
1 case when
select distinct t.rptid as rid,t.start_year as 起始年 ,t.start_month as 起始月 ,t.end_year as 截至年 , t.end_month
as 截至月,
( case when t.reporttype = 'month' then '月報'
else '年報'
end)as 報表型別 ,( case when t.reporthome = 'gf' then '股份'
else '集團'
end) as 報表歸屬, t.operationname as 修改人,t.operationtime as 修改日期 ,v.rvversion as 版本
from report_rate t join rptversion v on t.rptvid=v.rvid left join reportinfo r on t.rptcode=r.rptcode order by t.rptid
2 decode
select distinct t.rptid as rid,t.start_year as 起始年 ,t.start_month as 起始月 ,t.end_year as 截至年 , t.end_month
as 截至月,
( case when t.reporttype = 'month' then '月報'
else '年報'
end)as 報表型別 ,( case when t.reporthome = 'gf' then '股份'
else '集團'
end) as 報表歸屬, t.operationname as 修改人,t.operationtime as 修改日期 ,v.rvversion as 版本
,decode(t.reporthome,'gf','股份','jt','集團','其他')
from report_rate t join rptversion v on t.rptvid=v.rvid left join reportinfo r on t.rptcode=r.rptcode order by t.rptid
3 repalce
select
replace(replace(t.reporthome,'jt','集團'),'gf','股份')
from report_rate t
start with onnect by prior 1,
select t.ciid ,t.cicode,t.ciscode,t.ciname name,t.cispcode parentid,t.corbelong,
p.ciscode pscode,p.ciname pname,t.ciname
from corinfo t,(select * from corinfo ci where ci.civalid='1') p
where 1=1 and t.cispcode = p.cicode(+) and t.corbelong ='gf'
and t.ciscode not like 't%' and t.ciscode not like 'ut%' and t.ciscode not like 'ld%' and t.ciscode not like 'hw%'
order by t.ciscode desc ,
2,select t.ciid ,t.cicode,t.ciscode, t.ciname name,t.cispcode parentid, p.ciscode pscode,p.ciname pname ,t.cilevel,b.cbfolder,t.ciname
from corinfo t,corboe b,(select * from corinfo ci where ci.civalid='1') p
where 1=1 and t.civalid = '1' and
t.ciid = b.ciid and b.cbvalid = 1 and t.cispcode = p.cicode(+)
and t.rvid is not null
and t.corbelong ='gf'
and t.ciscode not like 't%' and t.ciscode not like 'ut%' and t.ciscode not like 'ld%' and t.ciscode not like 'hw%'
start with t.cispcode = 0 connect by prior t.cicode = t.cispcode order by t.ciname asc
oracle 字元替換
摘自 使用replace函式 測試語句 select replace 你好變 變 站 from dual 正式語句 update test set name replace name,變 站 可以切割字串 測試語句 selectreplace substr xx變 xx變 1,instr xx變 x...
oracle實現字串擷取,查詢,替換
1 字串擷取 substr substr string,start position,length 其中,string是元字串,start position為開始位置 注意首位從0開始 length是可選項,表示子字串的位數。eg 1 substr abcdefg 0 返回結果是 abcdefg,從...
字串替換數字
法一 create function f str str varchar 400 returns varchar 400 asbegin while patindex 0 9 str 0 begin set str stuff str,patindex 0 9 str 1 endreturn str...