SQL语句,一共有5个变量,只要满足其中任意三个变量或以上的SQL语句怎么写?
展开全部
select *
from table
where 1=1
and (
case when condition1(@arg1) is true then 1 else 0 end
+ case when condition2(@arg2) is true then 1 else 0 end
+ case when condition3(@arg3) is true then 1 else 0 end
+ case when condition4(@arg4) is true then 1 else 0 end
+ case when condition5(@arg5) is true then 1 else 0 end
) >= 3
from table
where 1=1
and (
case when condition1(@arg1) is true then 1 else 0 end
+ case when condition2(@arg2) is true then 1 else 0 end
+ case when condition3(@arg3) is true then 1 else 0 end
+ case when condition4(@arg4) is true then 1 else 0 end
+ case when condition5(@arg5) is true then 1 else 0 end
) >= 3
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询