5 Replies Latest reply: May 22, 2010 10:57 AM by Martha Thompson RSS

    2 Left Joins To One Table?

    Martha Thompson

      In the example below I am loading a table then attempting to do 2 left joins to this table. The first left join (Parts) works fine. But I end up without any records from the second join (Labor). In the Script Execution window it appears that nearly 1 million labor records are being loaded.

      If I comment out the "parts" left join then the "labor" left join works correctly. What am I missing here? In a previous Qlikview app I was able to do a second left join to a table, the only difference was the second join was to a resident table.

      Thanks in advance for any help. Here is my script:

      VendorPerformanceInvoices:
      LOAD [Charge-cust],
      Document,
      [Equipment-cust] AS [Vendor-code],
      [Invoice-date],
      [Invoice-Type],
      [Seq-no],
      [Wo-no]
      FROM
      ..\DataSources\VendorPerf.qvd
      (qvd)
      WHERE [Invoice-Type] <> 'Sales';

      LEFT JOIN (VendorPerformanceInvoices)
      LOAD
      'Parts' AS SubCategory,
      Cost AS UnitCost,
      [Item-no],
      [Net-price] AS UnitPrice,
      [Qty-shipped],
      [Seq-no],
      [Qty-shipped] * [Net-price] AS SaleAmt,
      [Qty-shipped] * Cost AS CostAmt
      FROM
      ..\DataSources\Invoice_Line.qvd
      (qvd)
      WHERE EXISTS([Seq-no]);

      LEFT JOIN (VendorPerformanceInvoices)
      LOAD
      'Labor' AS SubCategory,
      Time_Type,
      [emp-id],
      [wo-no],
      [Sheet-date],
      Hours,
      [Cost-rate],
      [Charge-amt],
      // Document,
      [Seq-no],
      [Cost-rate] * [Hours] AS [Actual-labor-cost]
      FROM
      "..\DataSources\[ST-TIME-SH].qvd"
      (qvd)
      WHERE EXISTS([Seq-no]);