15 Replies Latest reply: Mar 18, 2014 6:09 PM by Aji Paul RSS

    Looping through table and creating Dynamic columns

      I have the following table ORDER

       

      CUST_IDORD_YEARAmount
      A200810
      A200815
      A200915
      A201020
      A20125
      A201410
      A201420
      B200810
      B20085
      B200825
      B200930
      B20135
      B201310
      B20145

       

      Would like to create a summary table as shown below ORD_SUMM

       

      CUST_ID200820092010201220132014
      A2515205 30
      B4030 155

       

      Tried the for loop but its throwing error.

       

      Let vYRVal = min(ORD_YEAR);

      for i=min(ORD_YEAR) to year(Today(0))

      ORD_SUMM:

      load

          CUST_ID,

          SUM(Amount) as $(vYRVal)

      Resident

          ORDER

      where

          ORD_YEAR = $(vYRVal)

      group by

          CUST_ID;

      vYRVal = $(vYRVal)+1;

      next

      drop table ORDER;

       

       

      Any Idea on how to do this?