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="http://12723.xxkk.net">学习中</a>
相似回答