1. to_char(date,str)把指定日期转换为字符,还可以截取到想要的内容,如单独的年,月,日
select to_char(sysdate,'yyyy')from dual---2011
select to_char(sysdate,'fmyyyy-mm-dd')from dual-- 2011-6-9 fm取消月日前面的0
select to_char(sal,'L999,999,999') from emp-- $8,000 把数字换成美元
2. to_number(arg)把arg转换为数字类型
select to_number('13')+to_number('14') from dual—27
3. to_date(arg1,arg2)把字符转化为日期
select to_date('20110206','yyyy-MM-dd') from dual;
4. nvl(exp1,exp2)返回非空exp
select nvl(comm,0) from emp
5. nullif(exp1,exp2)如果exp1=exp2,那么返回null,如果不相等,返回exp1
select nullif('aaa','aaa') from dual---null
6. nvl2(exp1,exp2,exp3)---如果exp1为空,返回3,如果exp1不为空,返回exp2
select nvl2('','bbb','ccc') from dual---ccc
7. coalesce(Nexp)返回第一个非null值,可以是N个exp
select coalesce('','','cc') from dual---cc
8. case exp1 when value1 then else end;实现多路分支结构
select empno,ename,sal,
case deptno
when 10 then '财务部'
when 20 then '研发部'
when 30 then '销售部'
else
'unkown'
end
from emp;
9. decode(exp,value1,str1,value2,str2,str3)也是实现多路分支结构
select empno,ename,sal,
decode(deptno,10,'aaa',20,'bbb','未知部门') from emp
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25676270/viewspace-697595/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25676270/viewspace-697595/