Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rogeriogyn
Partner - Contributor III
Partner - Contributor III

Nested loops - high time cost

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.

1 Reply
jerrysvensson
Partner - Specialist II
Partner - Specialist II

Have you looked at IntervalMatch()?