22,207
社区成员
发帖
与我相关
我的任务
分享
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([a] int,[b] int)
insert [tb]
select 1,2 union all
select null,3 union all
select 1,3 union all
select 3,null
go
select *
from tb
where case when b is null or b=1 then a else b end=3
/**
a b
----------- -----------
NULL 3
1 3
3 NULL
**/
isnull(B,A)=条件
--try
where isnull(b,a)=@参数