设为首页 加入收藏

TOP

SQL中ISNULL用法示例
2014-11-23 20:26:08 来源: 作者: 【 】 浏览:17
Tags:SQL ISNULL 用法 示例
SQL中ISNULL用法示例
ISNULLSQL查询示例SELECT
ISNULL
使用指定的替换值替换 NULL。
语法
ISNULL ( check_expression , replacement_value )
参数
check_expression
将被检查是否为 NULL的表达式。check_expression 可以是任何类型的。
replacement_value
在 check_expression 为 NULL时将返回的表达式。replacement_value 必须与 check_expresssion 具有相同的类型。
返回类型
返回与 check_expression 相同的类型。
注释
如果 check_expression 不为 NULL,那么返回该表达式的值;否则返回 replacement_value。
示例
1 示例数据
表tb_Student及其示例数据如下图所示。
2 查询要求
查询出其中成绩(score)小于等于60的学生信息保存至表变量@tempTable中,当学生成绩为空时,成绩记为0。
[csharp]
declare @tempTable table(  
    stuname nchar(10),  
    stuage int,   
               stuscore float);  
insert into @tempTable  
select name,age,ISNULL(score,0) from tb_Student  
where  ISNULL(score,0)<=60  
select * from @tempTable  

3 执行结果
好了,就到这里了。
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇SQL Server 2012入门图解(一):.. 下一篇SQL With ties的理解“与”

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: