select nvl(sum(t.dwxhl),1) from tb_jhde t where
zydm=-1这里关心的nvl的用法,nvl(arg,value)代表如果前面的arg的值为null那么返回的值为后面的value
54ne.com
另一个有关的有用方法
declare
i integer
select nvl(sum(t.dwxhl),1) into i from tb_jhde t where
zydm=-1这样就可以把获得的合计值存储到变量i中,如果查询的值为null就把它的值设置为默认的1
oracle的substr函数的用法
取得字符串中指定起始位置和长度的字符串 substr( string, start_position, [ length ] )
如:
substr('This is a test', 6, 2) would return 'is'
substr('This is a test', 6) would return 'is a test'
substr('TechOnTheNet', -3, 3) would return 'Net'
substr('TechOnTheNet', -6, 3) would return 'The'
select substr('Thisisatest', -4, 2) value from dual
decode(字段,'a','男','b','女','c','未知')from 表
decode(sign(字段-60),-1,'及格',‘不及格’)from 表
select * from stu;
ID
NAME
CJ
--------------------------------------- ------------
---------------------------------------
1
JIM
88
2
jom
75