需要从连接获取数据的附加条件

Need additional condition on getting data from join

我还需要从 referrf 导入另一个数据,但不确定如何操作。我还需要所有行 从 astdta.referrf 那里 RFCAT = '8799' 和 RFSQ2 = '1' 然后给我们列 RFSLC - 如果我添加这个我没有结果> AND T02.rfcat = '8799'

CREATE VIEW rklib.CLSPAYTPP AS
    SELECT ALL 
         T01.OTCOM#, T01.OTORD#,                                                                 
         t01.ottRND, T01.OTTRT,                                             
         T01.OTUSRN, T01.OTTRNC, T01.OHPTTC, T01.OHSLR#, 
         t01.OHORDT,                                                           
         T01.OHORDD, T01.OHTTN$, T02.RFCAT, T02.RFSLC, T02.RFSQ2,                                                                     
         t02.RFDTA                                                                  
    FROM ASTDTA.CLSPAYT2 T01 INNER JOIN
         ASTDTA.REFERRF T02
         ON T01.OTTRNC = T02.RFSLC WHERE RFCAT = '5058' AND RFSQ2 = '1'  

我想你可以使用 IN 子句:

CREATE VIEW rklib.CLSPAYTPP AS
    SELECT ALL 
         T01.OTCOM#, T01.OTORD#,                                                                 
         t01.ottRND, T01.OTTRT,                                             
         T01.OTUSRN, T01.OTTRNC, T01.OHPTTC, T01.OHSLR#, 
         t01.OHORDT,                                                           
         T01.OHORDD, T01.OHTTN$, T02.RFCAT, T02.RFSLC, T02.RFSQ2,                                                                     
         t02.RFDTA                                                                  
    FROM ASTDTA.CLSPAYT2 T01 INNER JOIN
         ASTDTA.REFERRF T02
         ON T01.OTTRNC = T02.RFSLC WHERE RFCAT IN ('5058','8799') AND RFSQ2 = '1'