将 Access IIF 语句转换为 Oracle Case 语句
Convert Access IIF Statement to Oracle Case Statement
有人知道如何将 Access SQL IIF 语句转换为 Oracle/SSMS CASE 语句吗?先感谢您。请看下面的表达式
(Type NOT IN ('Swap') AND Mat_Date <= Eff_Date)
OR (Type = 'SWAP' AND iif(First_Date_pay < First_Date_rec, First_Date_pay,
First_Date_rec) < DateAdd("d", 150, Trd_Date) AND Mat_Date <= Eff_Date)
不要在 where
子句中使用 case
或 iif()
。相反,只需使用常规布尔逻辑。在您的情况下,您只需要 least()
函数(假设值不是 NULL
):
where (Type not in ('Swap') and Mat_Date <= Eff_Date
) or
(Type = 'SWAP' and
least(First_Date_pay, First_Date_rec) < Trd_Date + interval '150' day and
Mat_Date <= Eff_Date
)
有人知道如何将 Access SQL IIF 语句转换为 Oracle/SSMS CASE 语句吗?先感谢您。请看下面的表达式
(Type NOT IN ('Swap') AND Mat_Date <= Eff_Date)
OR (Type = 'SWAP' AND iif(First_Date_pay < First_Date_rec, First_Date_pay,
First_Date_rec) < DateAdd("d", 150, Trd_Date) AND Mat_Date <= Eff_Date)
不要在 where
子句中使用 case
或 iif()
。相反,只需使用常规布尔逻辑。在您的情况下,您只需要 least()
函数(假设值不是 NULL
):
where (Type not in ('Swap') and Mat_Date <= Eff_Date
) or
(Type = 'SWAP' and
least(First_Date_pay, First_Date_rec) < Trd_Date + interval '150' day and
Mat_Date <= Eff_Date
)