Hello. This is a little difficult to explain....
I have a table with the following table:
I am trying to place no more than 30 units into a folder name.
I would like to take the 'pages' value for row1 and if it is less than 30, update a folder name.
Then I would like to add in row2 pages and if the total for row 1 and 2 are less than 30 then update to the same folder name.
Then I would like to add in row3 pages. If the pages total for rows 1,2,3 exceed 30 then I need to start a new folder name for row 3.
I'm hoping to end up with something like this:
Counter[tab]pages [tab]Folder
1 [tab] 12 [tab] Folder1
2[tab] 13[tab] Folder1
3[tab] 6[tab] Folder2 [tab](This is a next folder because it would take my sum total for Folder1 over 30)
4[tab] 2[tab] Folder2
5[tab] 1[tab] Folder2
6[tab] 9[tab] Folder2
7[tab] 17[tab] Folder3 [tab](This is the next folder because it would take my sum total for Folder2 over 30)
8[tab] 10[tab] Folder3
9[tab] 11[tab] Folder4 [tab](This is the next folder because it would take my sum total for Folder3 over 30)
10[tab] 1[tab] Folder4
I am trying to do this with some while loops, but my I'm putting While scripts within while scripts and I am not getting it correctly.
Any ideas?
I have a table with the following table:
Code:
create table mytable1 (counter int, pages int, Folder varchar(100))
insert into mytable1 (counter, pages) values (1, 12)
insert into mytable1 (counter, pages) values (2, 13)
insert into mytable1 (counter, pages) values (3, 6)
insert into mytable1 (counter, pages) values (4, 2)
insert into mytable1 (counter, pages) values (5, 1)
insert into mytable1 (counter, pages) values (6, 9)
insert into mytable1 (counter, pages) values (7, 17)
insert into mytable1 (counter, pages) values (8, 10)
insert into mytable1 (counter, pages) values (9, 11)
insert into mytable1 (counter, pages) values (10, 1)
I am trying to place no more than 30 units into a folder name.
I would like to take the 'pages' value for row1 and if it is less than 30, update a folder name.
Then I would like to add in row2 pages and if the total for row 1 and 2 are less than 30 then update to the same folder name.
Then I would like to add in row3 pages. If the pages total for rows 1,2,3 exceed 30 then I need to start a new folder name for row 3.
I'm hoping to end up with something like this:
Counter[tab]pages [tab]Folder
1 [tab] 12 [tab] Folder1
2[tab] 13[tab] Folder1
3[tab] 6[tab] Folder2 [tab](This is a next folder because it would take my sum total for Folder1 over 30)
4[tab] 2[tab] Folder2
5[tab] 1[tab] Folder2
6[tab] 9[tab] Folder2
7[tab] 17[tab] Folder3 [tab](This is the next folder because it would take my sum total for Folder2 over 30)
8[tab] 10[tab] Folder3
9[tab] 11[tab] Folder4 [tab](This is the next folder because it would take my sum total for Folder3 over 30)
10[tab] 1[tab] Folder4
I am trying to do this with some while loops, but my I'm putting While scripts within while scripts and I am not getting it correctly.
Any ideas?