oracle 工作中遇到的函数
?--decode語法 decode(條件,值1,翻譯值1,值2,翻譯值2)
??????????????? --decode(字段,比較1,值1,比較 2,值2)
?? decode((select count(1)
???????????????????????? from commnct_notification f
??????????????????????? where f.parent_id = t.notification_id),
?????????????????????? 0,
?????????????????????? 'true',
?????????????????????? 'false')
? DECODE(T.VALUE_BOOL,'0','否','1','是'),
?select decode (u.gender ,0,'男',1,'女') sex? from sys_user u
?
.Round (數(shù)值的四舍五入)
SELECT Round(123.456,1)FROM Dual;
Trunc (截取日期和數(shù)字處理)
select substr(to_char(sysdate,'yyyyMMdd'),3,6) from dual;
?
Substr (字符串的截取)
?
Substr(字符串,截取開始位置,截取長度)
Substr('HelloWorld',1,1)//返回結(jié)果為'h'*0和1都是表示截取的開始位置為第一個(gè)字符
Substr('HelloWorld',2,4)//返回結(jié)果為'Ello'
to_char(日期轉(zhuǎn)換成字符串);?
to_char(sysdate, 'yyyy/MM/dd'))? from dual;
select to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss')??? from dual//
?
Nvl (數(shù)據(jù)表字段的判空處理)
select nvl(max(t.sort_order), 0) + 1 CODE
????? FROM PM_WBS_RELATION? t
?? WHERE T.PARENT_TASK_ID = '6D170892332141A8B5FD41676C91D6EC' ;
start with (樹遞歸)
SELECT FROM PM_TASK_OBJECT T, PM_WBS_RELATION T1
?WHERE T.TASK_ID = T1.CHILD_TASK_ID
?START WITH t1.parent_task_id = ''
??????? and t.task_status = 'planning'
CONNECT BY PRIOR t.task_id = t1.parent_task_idwg
逆向遞歸
connect by prior t.parent_id = t.notification_id\n"
?? ??? ??? ??? ?+ " start with t.notification_title like '%"
?? ??? ??? ??? ?+ vo.getNotificationTitle() + "%' ";
unill 合并 unillALL(union和union all的區(qū)別是,union會(huì)自動(dòng)壓縮多個(gè)結(jié)果集合中的重復(fù)結(jié)果,而union all則將所有的結(jié)果全部顯示出來,不管是不是重復(fù)。 )
select pm.PROGRESS_PERCENTAGE progress, t.activity_name name,'上游' type
? from ENGINE_ACTIVITY t, pm_task_object pm
?where t.activity_id in
?????? (select t.from_activity_id
????????? from engine_transition t
???????? where t.to_activity_id in
?????????????? (select t.activity_id
????????????????? from ENGINE_ACTIVITY_ACTION t
???????????????? where t.action_id = '63A52773930B48EB93A14B296DD77090' and pm.task_id='63A52773930B48EB93A14B296DD77090'))
union
select pm.PROGRESS_PERCENTAGE,t.activity_name name, '下游' type
? from ENGINE_ACTIVITY t, pm_task_object pm
?where t.activity_id in
?????? (select t.to_activity_id
????????? from engine_transition t
???????? where t.from_activity_id in
?????????????? (select t.activity_id
????????????????? from ENGINE_ACTIVITY_ACTION t
???????????????? where t.action_id = '63A52773930B48EB93A14B296DD77090' and pm.task_id='63A52773930B48EB93A14B296DD77090'))
轉(zhuǎn)載于:https://www.cnblogs.com/chizizhixin/p/5772937.html
總結(jié)
以上是生活随笔為你收集整理的oracle 工作中遇到的函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [转]一些需要禁用的PHP危险函数和禁用
- 下一篇: [图解tensorflow源码] [原创