时间:2021-07-01 10:21:17 帮助过:72人阅读
今天在一个应用中使用到了一个比较特殊的数据查询要求。需要的朋友可以参考下。
举例如下:
SELECT * FROM DemoTable
WHERE ((SELECT CASE 1 WHEN condition1满足条件 THEN 1 ELSE 0 END FROM DemoTable )
+(SELECT CASE 1 WHEN condition2满足条件 THEN 1 ELSE 0 END FROM DemoTable)
+(SELECT CASE 1 WHEN condition3满足条件 THEN 1 ELSE 0 END FROM DemoTable)
+(SELECT CASE 1 WHEN condition4满足条件 THEN 1 ELSE 0 END FROM DemoTable)
+(SELECT CASE 1 WHEN condition5满足条件 THEN 1 ELSE 0 END FROM DemoTable))>=2