下面是我的sql语句
select No,
       (case Data_Type
          when '1' then BodyDate_T.Body_Data   end) as type1,
            (case Data_Type
          when '2' then BodyDate_T.Body_Data end) as type2,
           (case Data_Type
          when '3' then BodyDate_T.Body_Data  end) as type3,
          BodyDate_T.UpdateDatetime
 from BodyDate_T 
 order by BodyDate_T.UpdateDatetime执行的结果如下
No type1 type2 type3 UpdateDatetime
201 NULL 32 NULL 2010-01-10 08:42:05
202 NULL NULL NULL         2010-01-10 08:42:05
203 42 NULL NULL            2010-01-10 08:42:05
204 NULL NULL 50         2010-01-10 08:42:35怎样才能将三者都不符合的数据不显示(想要的结果如下)
No type1 type2 type3 UpdateDatetime
201 NULL 32 NULL 2010-01-10 08:42:05
203 42 NULL NULL            2010-01-10 08:42:05
204 NULL NULL 50         2010-01-10 08:42:35
SQLcase

解决方案 »

  1.   

    SELECT * FROM (
    select No,
           (case Data_Type
              when '1' then BodyDate_T.Body_Data   end) as type1,
                (case Data_Type
              when '2' then BodyDate_T.Body_Data end) as type2,
               (case Data_Type
              when '3' then BodyDate_T.Body_Data  end) as type3,
              BodyDate_T.UpdateDatetime
     from BodyDate_T)  a
    where type1 is not null and type2 is not null type3 is not null
     order by BodyDate_T.UpdateDatetime
      

  2.   


    不行,报出列名'type1'无效
      

  3.   


    试好了,应该是用or而不是and 
    谢谢了啊
      

  4.   

    where type1 is not null or  type2 is not null or type3 is not null