当B表有数据时---------- select count(*) from b select a1,a2 from a where a1='**' and b1='**'当B表没有数据时select a1,a2 from a where a1='**' 这种不同情况查询条件不同的SQL怎么写,sqlserver。我直接在where后面写case when 总是报错。select * from RD_Craft where status != 0 and userright like '%,${fine_username},%' case when (select COUNT(*) from fine_user t1 left join fine_user_role_middle t2 on t1.id = t2.userid where t2.roleid = 'a89c174d-5938-4a94-b642-f836af54cb33' and username ='${fine_username}') > 0 then "and 1=2" else "and 1=1" endUNION allselect * from RD_Craft where status != 0 case when (select COUNT(*) from fine_user t1 left join fine_user_role_middle t2 on t1.id = t2.userid where t2.roleid = 'a89c174d-5938-4a94-b642-f836af54cb33' and username ='${fine_username}') > 0 then "and 1=1" else "and 1=2" end