0

我需要在 nvl 类型 fn 上使用 python 连接两个表,因为我们有一个表,根据部件类型,我们只输入前 7 个字符。

到目前为止,我还没有找到在 python 中执行此操作的简单方法。
是否有一个功能可以做到这一点,或者另一种简单的方法来实现它?

先感谢您

我加入了 part_number,删除了另一个表的字段为 NaN 的位置,然后作为子字符串上的新表加入,然后将表附加在一起。并以错误的行数结束。

left join on nvl(nvl(thistable.part_number, substr(thistable.part_number, 1, 7)),'not in defn table') = part_number.othertable

输出可能是这样的:

thistable.part_number    othertable.description
abc123                   real part
def456                   another real part
1234567-02               part stored as 1234567 in othertable
koue49c                  not in defn table
4

1 回答 1

0

我想你想要coalesce()

on coalesce(thistable.part_number, substr(thistable.part_number, 1, 7), 'not in defn table') = part_number.othertable

coalesce()接受多个参数,因此您不需要嵌套函数调用。

于 2019-06-11T21:00:34.470 回答