1 Reply Latest reply: Jun 1, 2012 12:27 PM by Stefan Wühl RSS

    Scripting question / Adding two columns

      Hello everyone,

       

      I am facing a (i'm sure it is) really easy problem...

       

      I have two tables, let's say :

      TableA :

      LOAD

      dim1,

      dim2,

      dim3,

      metricA

      FROM a.qvd (qvd);

       

      TableB :

      LOAD

      dim1,

      dim2,

      metricB

      FROM b.qvd (qvd);

       

      In the end, i'd like to have a Table C with the following columns :

      dim1,

      dim2,

      dim3,

      metricA + metricB

       

      Thanks a lot for your help.

       

      Damien

        • Scripting question / Adding two columns
          Stefan Wühl

          If I understood correctly, you should be able to join the two tables and then do a rangesum of fields metricA and metricB, maybe like this (untested):

           

          TableA :

          LOAD

          dim1,

          dim2,

          dim3,

          metricA

          FROM a.qvd (qvd);

           

           

          left join (TableA) LOAD

          dim1,

          dim2,

          metricB

          FROM b.qvd (qvd);

           

          Result:

          LOAD *, rangesum(metricA,metricB) as SumOfMetrics resident TableA;

           

          drop table TableA,

          //drop fields metricA,metricB; //drop if needed