sql如何判断字段的值是不是空值

如:
select (t.num_1 + t.num_2) from table t

字段num_1有可能为null ,如果该条记录的num_1为空值,则用0和num_2相加。这个sql语句怎么写。
最好oracle和sql server的都写写。

在sql中
空值有NULL 和''的形式
当是NULL的时候用 IS NULL判断
当是''的时候用 =''判断
比如
select * from table where enddate IS NULL;
select * from table where str='';
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-10-06
oracle:
select (nvl(t.num_1, 0)+t.num_2) from table t

sql server:
select (isnull(t.num_1, 0)+t.num_2) from table t本回答被提问者采纳
第2个回答  2009-08-12
select (nvl(t.num_1, 0)+t.num_2) from table t
第3个回答  2009-08-12
用isnull方法判断为空不为空~
第4个回答  2009-08-12
<a href="">学习中</a>

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网