teradata中基于条件的sql连接

ttcibm8c  于 2021-08-09  发布在  Java
关注(0)|答案(1)|浏览(292)

我试着写下这样的东西:

case when table_1.account_or_client='A' then inner join on table_1.addr_id=table_2.addr_id where substr(table_2.addr_id,2,1) is not 0
else then inner join on table_1.addr_id=table_2.addr_id

但是用正确的语法。我该怎么做?
当表\u 1.account\u或\u client='a'连接时,我需要确保表\u 2.addr\u id的第二个数字不是0

8yparm6h

8yparm6h1#

当表\u 1.account\u或\u client='a'转换为

FROM table_1 AS t1 
JOIN table_2 AS t2
  ON t1.addr_id=t2.addr_id
 AND NOT (t1.account_or_client='A' AND Substr(t2.addr_id,2,1) = '0')

相关问题