Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL and Sum in ASP

    In the following code
    SQL = "Select * From CouponCode Order By FromEmail"
    Set HRS = Conn.Execute(SQL)
    do until HRS.EOF
    Response.write HRS("CCDValue")
    HRS.movenext
    Loop

    would give me the last value in the list of fields in a table in my db so say I had three values 10 15 and 5 it would show me 5 how can I get it to show me 30 as that is the sum of the three values I tried

    SQLA = "Select Sum(CCDValue) From CouponCode"

    but dont know how to get the values!

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never mind I figured out what I was missing

    SQL = "Select Sum(CCDValue)as vol From CouponCode Where FromEmail = '" & Session("Useremail") & "'"

    Response.write HRS("vol")

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    on a sidenote, id use
    Code:
    Do While NOT HRS.EOF
    	....
    Loop
    i cant remember if this matters in asp, some other languages at least run untils at least once so an empty collection will still run once on eof (im really not sure about asp)


  •  

    Posting Permissions

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