10 Replies Latest reply: Oct 28, 2015 7:37 AM by Himanshi Dubey RSS

    Inner Join

    Andrew Thomas


      Hi

       

      I have 2 tables

       

      Table 1 contains the following and I have put in a where clause to reduce down the number of records being loaded.

       

       

      VBAP:

      LOAD MVGR1 As MatGrp1,
      WERKS As Plant,
      VBELN As SalesOrder,
      //POSNR As LineItem,
      MATNR As MatNo,
      PRODH As ProdH,
      if(PRODH = '539017' or PRODH = '539018' or PRODH = '539021' or PRODH = '539002' or PRODH = '5A9017' or PRODH = '5A9018' or PRODH = '5A9021' or PRODH = '5A9002' ,'Spares','Service') As ProdhType,
      NETWR As SalesOrderValue,
      WAERK As Currency,
      ZZRGIDAT As CustReqDate,
      ZZCCGDAT As CustCommitGIDate,
      [Plant Region] As Region,
      Market2 As Market

      FROM
      [D:\SourceDocuments\PRODQLIK\DATA\SAP DATA\VBAP.QVD]
      (
      qvd)

      Where
      //ZZRGIDAT > '08/01/2014'


      PRODH >= '539001' and PRODH <= '539021'
      or
      PRODH = '539024'
      or
      PRODH = '539028'
      or
      PRODH >= '539030' and PRODH <= '539035'
      or
      PRODH >= '539038' and PRODH <= '539042'
      or
      PRODH >= '5A9001' and PRODH <= '5A9021'
      or
      PRODH = '5A9024'
      or
      PRODH = '5A9028'
      or
      PRODH >= '5A9030' and PRODH <= '5A9035'
      or
      PRODH >= '5A9038' and PRODH <= '5A9042'
      ;

       

      Table 2 contains the following - I originally linked the 2 tables using a left join with the common field being VBELN, however that was causing me problems as table 1 only has 200,000 records but table 2 has over 7 million records.

       

      I want to only load the records in table 2 that appear in table 1, I thought the way to do this was to use an inner join but when I do this I still see 7 million records being loaded in the data load. I'm not sure if I'm approaching this correctly

       

       

       

       

      VBAK:

       

       

      LOAD VBELN As SalesOrder,
      [Sales Organization] As SalesOrg,
      VKBUR As SalesOffice,
      KUNNR As SoldToParty


      FROM
      [D:\SourceDocuments\PRODQLI