select a from b
where c=5
其中a有很多值,其中有一值为空(a 字段可以为空),
我怎么判断出来,并在报表中将空值生成 N/A
表 b  
  a          c
 1        5
  2          5
 NULL        5
  
我试过用case语句,但是不怎么判断为空的条件?

解决方案 »

  1.   

    select isnull(a,'N/A') as a,c
    from b
    where c=5
      

  2.   

    select case when a is null then 'N/A' else a end as a from b where c=5
      

  3.   

    select IsNull(a,'N/A'), from b
    where c=5
      

  4.   

    接着问一下,如果我要用selct * from b
    where c=5这时怎么 设置条件,为空的变为'N/A'
     其中有很多项为空,有没有更简单的方法。