8 Replies Latest reply: Oct 10, 2012 9:00 AM by Rebecca Molstad RSS

    Best way to create a generated column in a load statement based on ranges

    Andreas Gerold

      I wish to calculate a extra column based on the value of another columen based on ranges.

       

      Example:

       

      TableA

      Name  Price

      Bob   500

      Alice 234

      Carl  134

      Jane   40

      ...

      ...

       

       

      Labels

      Range                   Label

      0   <= Price < 100      Low

      100 <= Price < 300      Medium

      300 <= Price < 1000     Quite High       

      ...

      77000 <= Price < 100000 The Rest

       

      I want to ad an expression in my load script so that I based on the value of Price get a new column called label, so that the resulting table is like this:


      TableA

      Name  Price label

      Bob   500  Quite High

      Alice 234  Medium

      Carl  134  Medium

      Jane   40  Low

      ...

      ...

       

      So basically I want do do

      LOAD

           Name,

           Price,

           <something with price to map to a label> as label

      FROM

      .....

       

      Any suggestions on how to do this in a clean and efficient way?

       

      Thanks in advance.

      Andreas