1 Reply Latest reply: Apr 17, 2013 7:29 AM by Jerry Svensson RSS

    Nested loops - high time cost

    Rogerio Faria

      Ok, I'm stuck with this:

       

      I got 2 table, and I need a Result table, just as shown below:

       

      Table Groups
      GroupNameStartRangeEndRange
      Bevarages1100111007
      Food2100321010
      Canned301117301118

       

      Table Items


      IdItemDesc
      11001001Coke
      110010027up
      11001003Absolut Vodka
      11001004Duff
      21003001Ruffles
      21003002Pringles
      30117005Beans
      30117006Green Corn
      30118001Souce
      99903001Trim

       

      Result Table


      IdItemDescGroupName
      11001001CokeBevarages
      110010027upBevarages
      11001003Absolut VodkaBevarages
      11001004DuffBevarages
      21003001RufflesFood
      21003002PringlesFood
      30117005BeansCanned
      30117006Green CornCanned
      30118001SouceCanned
      99903001Trim-

       

       

       

      I did it with a  "for..for...next...next" nested loop, but it took a life, and I have only 1mi rows.

       

      Can anyone help me with this. I need a better way to do it.