T-SQL 中是否有三元条件运算符?

2021-09-10 00:00:00 tsql sql-server

实现以下查询的替代方法有哪些:

What are alternatives to implement the following query:

select *  
from table  
where isExternal = @type = 2 ? 1 : 0

推荐答案

使用case:

select *
from table
where isExternal = case @type when 2 then 1 else 0 end

相关文章