【问题标题】:Using a case statement in data validation在数据验证中使用 case 语句
【发布时间】:2015-07-13 17:10:07
【问题描述】:

我有两个表,t1 和 t2,与 ID 字段连接 我需要测试一下-

1. t1.ROE is 1 when t2.Currency1 = t2.Currency2
2. t1.ROE is equal to t2.ROE, otherwise

请帮我为它生成一个脚本。

【问题讨论】:

  • 欢迎来到stackoverflow。请阅读How to Ask。提示:向我们展示您已经尝试过的内容。

标签: sql sql-server where


【解决方案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))

【讨论】:

    猜你喜欢
    • 2017-07-26
    • 1970-01-01
    • 2018-07-18
    • 2021-08-26
    • 2016-05-02
    • 2020-01-17
    • 2021-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多