nested loops

1. Member
Join Date
Dec 1969
Posts
38

## nested loops

I am trying to generate a report of monthly revenue per service level (3 service levels) per currency (3 currencies). <BR><BR>I have a stored procedure that returns totalCost per job with service Level (1, 2, or 3), and currencyID (1, 2, or 3). <BR><BR>In ASP how can I organize the code so that it calculates the total revenue for each month catagorised by service level in all three currencies.<BR><BR><BR>Thank you.<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
2,049

## RE: Give an example of the results.

It&#039;s easier to see what you want.

3. Member
Join Date
Dec 1969
Posts
38

## RE: Give an example of the results.

Results for april should look like:<BR><BR>APRIL:<BR>======<BR><BR>serivce 1:<BR>----------<BR> \$15,194.49 £ 6,489.49 & 4,579.20<BR><BR>service 2: <BR>----------<BR> \$18,094.89 £ 2,420.49 & 8,579.50<BR><BR>service 3:<BR>---------- <BR> \$10,695.76 £ 8,426.49 & 4,475.47<BR><BR>and simmilarly for all other months.<BR>

4. Senior Member
Join Date
Dec 1969
Posts
1,849

## No need for nested loops I think

A single loop, and keep running totals of each category...<BR><BR>IE<BR>while not rs.eof<BR> if rs("field") = 1 then<BR> value1 = value1 + rs("value")<BR> elseif rs("field") = 2 then<BR> value2 = value2 + rs("Value")<BR> elseif rs("field") = 3" then<BR> value3 = value3 + rs("value")<BR>else<BR> response.write("error")<BR>end if<BR>rs.movenext<BR>wend<BR><BR>response.write("v alue1 : " & value1 & "<BR>")<BR>response.write("value2 : " & value2 & "<BR>")<BR>response.write("value3 : " & value3 & "<BR>")<BR>

5. Senior Member
Join Date
Dec 1969
Posts
2,049

## RE: Give an example of the results.

&#060;%<BR>Dim m<BR>For m = 1 To 12<BR>%&#062;<BR>&#060;table width="500" border="0" cellspacing="0" cellpadding="0"&#062;<BR> &#060;tr bgcolor="#CCCCCC"&#062; <BR> &#060;td colspan="3"&#062;&#060;font size="3" face="Geneva, Arial, Helvetica, san-serif"&#062;&#060;strong&#062;&nbsp;&#060;font color="#FFFFFF"&#062;&#060;%= MonthName(m) %&#062;&#060;/font&#062;&#060;/strong&#062;&#060;/font&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> <BR>&#060;%<BR>Dim RS<BR>SQL = "SELECT * FROM ServiceLevels "_<BR>& "WHERE Month(ServiceDate) = &#039;"& MonthName(m) &"&#039;"<BR>Set RS = objConnection.Execute(SQL)<BR><BR>Dim n &#039;number<BR>n = 1<BR><BR>While Not RS.EOF<BR>If n = 4 Then n = 1<BR>If n = 1 Then<BR>%&#062;<BR> &#060;tr&#062; <BR> &#060;td colspan="3"&#062;&#060;font color="#006699" size="2" face="Arial, Helvetica, sans-serif"&#062;&#060;strong&#062;&nbsp;&#060;%= RS("Service" %&#062;&#060;/strong&#062;&#060;/font&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;%<BR> End If<BR> %&#062;<BR> &#060;tr&#062; <BR> &#060;td&#062;&#060;%= RS("Currency1") %&#062;&#060;/td&#062;<BR> &#060;td&#062;&#060;%= RS("Currency2") %&#062;&#060;/td&#062;<BR> &#060;td&#062;&#060;%= RS("Currency3") %&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;%<BR> n=n+1<BR> RS.MoveNext<BR> Wend<BR> %&#062;<BR> &#060;tr&#062; <BR> &#060;td colspan="3"&#062;&nbsp;&#060;/td&#062;<BR> &#060;/tr&#062;<BR>&#060;/table&#062;<BR>&#060;%<BR>Next &#039; month<BR><BR>Set RS = Nothing<BR>%&#062;

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•