• SQL中ISNULL用法示例


    ISNULLSQL查询示例SELECT

    ISNULL
       使用指定的替换值替换 NULL。
    语法
          :ISNULL ( check_expression , replacement_value )
    参数
       check_expression  将被检查是否为 NULL的表达式。如果不为NULL,这直接返回 该值,也就是 check_expression 这个表达式。如果为空这个直接返回 replacement_value这个表达的内容。。。。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。
    1 declare @tempTable table(  
    2     stuname nchar(10),  
    3     stuage int,   
    4      stuscore float);  
    5 insert into @tempTable  
    6 select name,age,ISNULL(score,0) from tb_Student  
    7 where  ISNULL(score,0)<=60  
    8 select * from @tempTable  

    3 执行结果

    明白了吗》》。

  • 相关阅读:
    泛型
    内部类 及 匿名内部类
    BigDecimal
    JodaTime简介
    Java中IO流
    Spring的ApplicationEvent的使用
    swagger文档使用(springboot项目)
    http连接过程遇到的各种性能瓶颈
    http网络连接过程
    python中的TypeError: 'NavigableString' object is not callable错误
  • 原文地址:https://www.cnblogs.com/linjulin/p/5691373.html
Copyright © 2020-2023  润新知