## Solution for total of rolling quarters...Database

Hi <BR>I have written code to output the total of a column for each quater of the year. It has a final output of each total for each quarter of the present year. My problem now is that I have to alter this s it is on a rolling basis. si I have to put out the totals for the last 4 quarters i.e. if it is currently q2 in year 2003 I need to output the totals for q2 2003, q1 2003 , q4 2002, q3 2002 and so on if the quarter moves into the next phase. I am having trouble trying to get my head round this. Would a database be the best solution and if it is how am I goin to have it so the page is only run every quarter to insert the latest figures into the database. <BR>Here is my current code for finding the totals for each quarter of the current year. I hope you understand my problem. Cheers <BR><BR>dim mthh, passArray(11), failArray(11), passWithConditionsArray(11), highRiskArray(11), mediumRiskArray(11), lowRiskArray(11) <BR> Yr=right(date(),4) <BR> <BR> &#039;The current month variable is used to draw the charts up to the present month <BR> currentMth = Month(Date) <BR> <BR> <BR> for mthh = 1 to currentMth <BR><BR> SQLSelManagement ="SELECT (SELECT count(projManagement) FROM [DAT] where projManagement = &#039;Pass&#039; and Month(projDate) = &#039;"& mthh &"&#039; and Year(projDate) = &#039;"& Yr &"&#039;) AS NumberPassed, " &_ <BR> "(SELECT count(projManagement) FROM [DAT] where projManagement = &#039;Fail&#039; and Month(projDate) = &#039;"& mthh &"&#039; and Year(projDate) = &#039;"& Yr &"&#039;) AS NumberFailed, " &_ <BR> "(SELECT count(projManagement) FROM [DAT] where projManagement = &#039;Pass With Conditions&#039; and Month(projDate) = &#039;"& mthh &"&#039; and Year(projDate) = &#039;"& Yr &"&#039;) AS NumberPassedWithConditions;" <BR> <BR> output.CursorType = 1 <BR> output.Open SQLSelManagement, oServer <BR> <BR> &#039;Response.Write "Month " & mthh & " Pass Rate is :"& output("NumberPassed") & " <BR>" <BR> passArray(mthh-1)=output("NumberPassed") <BR> &#039;Response.Write "Month " & mthh & " Fail Rate is :"& output("NumberFailed") & " <BR>" <BR> failArray(mthh-1)=output("NumberFailed") <BR> &#039;Response.Write "Month " & mthh & " Pass With Conditions Rate is :"& output("NumberPassedWithConditions")& " <BR>" <BR> passWithConditionsArray(mthh-1)=output("NumberPassedWithConditions") <BR> <BR> output.close <BR> next <BR> &#039;Calculating the Pass rate etc. for each quater <BR> firstQuaterPasses=passArray(0)+passArray(1)+passAr ray(2) <BR> secondQuaterPasses=passArray(3)+passArray(4)+passA rray(5) <BR> thirdQuaterPasses=passArray(6)+passArray(7)+passAr ray(8) <BR> fourthQuaterPasses=passArray(9)+passArray(10)+pass Array(11) <BR> <BR> firstQuaterPassWithConditions= passWithConditionsArray(0)+passWithConditionsArray (1)+passWithConditionsArray(2) <BR> secondQuaterPassWithConditions= passWithConditionsArray(3)+passWithConditionsArray (4)+passWithConditionsArray(5) <BR> thirdQuaterPassWithConditions= passWithConditionsArray(6)+passWithConditionsArray (7)+passWithConditionsArray(8) <BR> fourthQuaterPassWithConditions= passWithConditionsArray(9)+passWithConditionsArray (10)+passWithConditionsArray(11) <BR> <BR> firstQuaterFails=failArray(0)+failArray(1)+failArr ay(2) <BR> secondQuaterFails=failArray(3)+failArray(4)+failAr ray(5) <BR> thirdQuaterFails=failArray(6)+failArray(7)+failArr ay(8) <BR> fourthQuaterFails=failArray(9)+failArray(10)+failA rray(11) <BR>