8 Replies Latest reply: Jul 29, 2016 4:53 PM by Thirumala Dandamudi RSS

    Need help with Sum..Group by

    Wagner Takeda

      I have two tables right now, one of them is like this:

       

      IDQnt
      15
      26
      3

      7

       

      And the other is like this:

       

      ID

      Code

      1

      A

      2

      B
      3B

       

      I need to sum Qnt grouping by code (B would be 13 for example, since 6 and 7 are part of B), but when I try to do this, while I get the right numbers on B, A is returning me 10 instead of 5.

       

      This is the script that I'm using:

       

      Temp_Table:

      LOAD ID,

                Qnt,

      FROM Table_A.xlsx (ooxml, no labels);

      left join

      LOAD ID,

                Code

      FROM Table_B.xlsx (ooxml, embedded labels);

       

      Final_Table

      LOAD

          Code

          Sum(Qnt) as Result

      Resident Temp_Table Group By Code;

       

      Drop Table Temp_Table;

       

      What am I doing wrong? Thank you in advance for the help.