join在结果集中提供重复

时间:2014-05-27 21:50:29

标签: sql ibm-midrange db2-400

我们希望加入#部分。第一个表包含我们想要的大部分数据。第二个是每个零件的销售数据。只是浏览它的第一个表格给出了这个

TRUL02A           I          2,014    CRW                16.00-
CORGDFOIL         I          2,014    CRW             7,090.00-
FISTAS            I          2,014    CRW             5,716.00-
HWCR1             I          2,014    CRW            70,403.00-
HWFE1             I          2,014    CRW            52,317.00-
RO060             I          2,014    CRW            12,669.00-
MYCBOCB           I          2,014    CRW                66.00-
MY6BOCB           I          2,014    CRW                  .00 
MA20X3UL          I          2,014    CRW               167.00-
MA20X3CS1         I          2,014    CRW            72,978.00-

没有零件编号,但加入时 每个零件表的销售额我们得到重复。

SELECT                                                              
  ALL       T01.IAPRT#, T01.IA101, T01.IAPRLC, T01.IAUM, T01.IAPR$C,
T01.IARCC1,                                                     
T01.IARCC2, T01.IARCC3, T01.IARCC4, T01.IARCC5,                     
T01.IARCC6,                                                         
            T01.IARCC7, T01.IARCC8, T01.IARCC9, T01.IARC10,         
T01.IARC11,                                                         
            T01.IARC12, T01.IARC13, T01.IARC14, T01.IARC15,         
T02.IQYER#,                                                         
            T02.IQA01, T02.IQA02, T02.IQA03, T02.IQA04, T02.IQA05,  
T02.IQA06,                                                          
T02.IQA07, T02.IQA08, T02.IQA09, T02.IQA10, T02.IQA11,              
T02.IQA12,                                                          
T02.IQA13, T02.IQA14                                                
  FROM      ASTDTA.ICPRT1 T01 LEFT OUTER JOIN                       
            ASTDTA.ICSUM1 T02                                       
ON        T01.IAPRT# = T02.IQPRT#  

WHERE     IAORDF = '1'                      
  AND     IARCC6 = 'INV'                    
  AND     T02.IQYER# = 2014    

Gives duplicate data:

 AB25X5CL         2.5x5x1 CLEAR ACRYLIC BASE          CAC        EA          REC
 AB25X5CL         2.5x5x1 CLEAR ACRYLIC BASE          CAC        EA          REC
 AB25X5CL         2.5x5x1 CLEAR ACRYLIC BASE          CAC        EA          REC   

0 个答案:

没有答案