现有一个表
共5列
id varchar 50
name varchar 50
sex varchar 50
age varchar 50
grade varchar 50
都可以为空,现在要查询出表终任意两列不为空的记录。请问该怎么作啊?谢谢
------解决方案--------------------
--try
create table T(id varchar(50), name varchar(50), sex varchar(50), age varchar(50), grade varchar(50))
select * from T
where
(
(case when id is not null then 1 else 0 end)+
(case when name is not null then 1 else 0 end)+
(case when sex is not null then 1 else 0 end)+
(case when age is not null then 1 else 0 end)+
(case when grade is not null then 1 else 0 end)
)> 1