To find grantotal......

Results 1 to 2 of 2

Thread: To find grantotal......

  1. #1
    Join Date
    Dec 1969

    Default To find grantotal......

    Hi, I have the following data displayed on ASP page from the db.<BR><BR>username period_end_date Hrly rate hours Total<BR>UserA 02/12/01 50 200 10,000<BR> 02/28/01 60 100 6,000<BR>UserB 02/12/01 70 30 2,100<BR><BR>Now I need to find the grand total (Sum of all the total how do I do that?)help!!<BR>I have calculated total as Hrlyrate * hours. <BR>THANKS

  2. #2
    jamar Guest

    Default RE: To find grantotal......

    1. at the end of your sql statement add the following:<BR> "compute sum(Total) "<BR>2. now to access the computed field use the following code,<BR> assuming the name of the computed column will be referenced by the name "sum", and a recordset object named rs that is open:<BR><BR>3. Disclaimer: you could loop through rs and sum the "total" column in your code, but why bother when you can do in you sql statement.<BR>&#039;do original display stuff here...<BR><BR>do until rs is nothing<BR> if rs(0).name = "sum" then exit do<BR> set rs = rs.nextrecordset<BR>loop<BR><BR>if(isnull(rs(0).va lue) then TotalToDisplay = 0 else TotalToDisplay = rs(0).value <BR>&#039;notice we don&#039;t close because if the field "sum" is not found<BR>&#039;then the rs may = nothing so this would generate an error<BR>set rs = nothing

Posting Permissions

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