SQL 中case语句
下面是我的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