怎么样写才能得到sqlserver中的结果

解决方案 »

  1.   

    isnull是定空吧,select count(*) from table where a='user' and b is null;
      

  2.   

    oracle会把 '' 当左null的,而null 不能直接用来null = null的,除非在decode()函数中,oracle才认为null和null是相等的
    可以用 nvl(b,'') is null来判断
      

  3.   

    不好意思我表达的不好
    这是一个查询语句,其中a,b的查询值为ls_a,ls_b
    如果数据库中存在一条b=NULL的记录,我现在在oracle下就搜索不到select count(*) from table where a=:ls_a and nvl(b,'')=:ls_b;
      

  4.   

    由于在oracle中
    1、'' 和null表示一样的意思。
    2、null 与null无法进行相等比较。
    所以nvl(b,'')=''条件为false,则count(*)=0。
     bobo1314(bobo) 同学写的是对的。
      

  5.   

    我知道
     bobo1314(bobo) 同学写的是对的。但,我想知道我这个问题该怎么解决
      

  6.   

    明白你的意思declare 
    ls_a varchar2(20);
    ls_b varchar2(20);
    begin
    给ls_a,ls_b赋值;
    if ls_b is null then
    select count(*) from table where a=ls_a and b is null; 
    else
    select count(*) from table where a=ls_a and b=ls_b; 
    end if;
    end;
      

  7.   

    可以并成一句吗?ls_b<>null,但字段b可能为null
      

  8.   

    不是不是,你误会了:)
    我只不过是想,sqlserver能实现的功能,
    在ORACLE中怎么实现
      

  9.   

    申明:
    ls_b<>null,可能ls_b='',也可能为一长度不为0的字符串字段b则为3种情况null , '' , 长度不为0的字符串
      

  10.   

    可以并成一句吗?ls_b<>null,但字段b可能为null
    当然可以
    select count(*) from table where a=ls_a and nvl(b,'一个特殊的字符串')=ls_b;
    select count(*) from table where a=ls_a and nvl(b,'12345678900987654321')=ls_b
      

  11.   

    beauty_beast(柳随风):不对的
    要求:当 LS_B=''时,字段b中的内容可以为'',也可以为nullsqlserver:
    select count(*) from table where a='user' and isnull(b,'')='';
      

  12.   

    加上长两不就行了吗.
    select count(*) from table where a='user' and isnull(b,'null')<>'null';