我有两个表,t1和t2,与ID字段连接 我需要测试一下 -
1. t1.ROE is 1 when t2.Currency1 = t2.Currency2
2. t1.ROE is equal to t2.ROE, otherwise
请帮我为它生成一个脚本。
答案 0 :(得分:1)
尝试使用or
运算符,如下所示:
select *
from t1
join t2 on t1.id = t2.id
and ((t1.ROE = 1 and t2.Currency1 = t2.Currency2) or(t1.ROE <> 1 and t1.ROE = t2.ROE))