我在查询时,要查一个字段——qzdflag,该字段的值为:null,0,1
现在查询时,当qzdflag=1时,在数据浏览控件上显示:“达到”,其他两种情况为:“未达”
我该怎么处理了?
麻烦高手们指点下。
谢谢!

解决方案 »

  1.   

    select isnull(qzdflag,0) as qzdflag from table
    把null转换为0,不就可以了吗?
      

  2.   

    select case when qzdflag is null then '未达' else case qzdflag when 0 then '未达' when 1 then '达到' end end as qzdflagname from ...
      

  3.   

    上面一楼的朋友,可不可以在具体点了?
    我的意思是:查询时,当qzdflag=1时,在数据浏览控件上显示:“达到”,其他两种情况为:“未达” 
      

  4.   

    select case isnull(qxdflag, 0) when 0 then '未达' else '已达' end as qxdflagname from ...
      

  5.   

    select * from tablename where  isnull(qxdflag, 0)=0 --未达
    select * from tablename where  isnull(qxdflag, 0)=1 --已达
      

  6.   

    就是用case语句来查询.
    如果是oracle除了用case还可以用decode.create table a1(a int)
    insert into a1 values(null);
    insert into a1 values(1);
    insert into a1 values(0)select case when a is null then '未达'
                when a=1 then '到达'
                when a=0 then '未达'
           end as a
    from a1
      

  7.   

    select 是否达到=
        case qzdflag
        when 1 then '达到'
        when 0 then '未达'
        when null then '未达'
    From your_table
    sql server 语法