Posted on 2011-10-03
Last Modified: 2012-08-13
I need to buld report for many customers , and gives me total amount for every customer, then total for all of them,no worries about dataconnection, Thanks

CustomerName,Item, Amount

Total 'CustomerName'

Total all Customers
Question by:samprg
    LVL 28

    Expert Comment

    I can handle it 2 ways, one via sql query:

    Select customer, Amount, Item, SUM(IsNull(Amount,0)) as IndividualTotal from yourtable where name ='SomeName'
    Select customer, Amount, Item, SUM(IsNull(Amount,0) as GrandTotal from your table
    GROUP BY customer, AMount, Item

    OR a simpler way since you are using asp:

    SQLStr="Select customer, amount, item from your table"
    set rs=conn.execute(SQLstr)

     EachTotal= 0.00
     GrandTotal = 0.00

     Do While Not rs.EOF

          custname = rs("customer")
                    item        = rs("item")
                    amount = rs("amount")
          if isnull(rs("amount")) then
                eachTotal = 0.00
          end if

    EachTotal=EachTotal+amount 'This gives you individual total

    GrandTotal= GrandTotal+ EachTotal 'This gives you Total for all customers


    Customer A's total = <%=formatcurrency(EachTotal,2)%>

    All Customers' totals = <%=formatCurrency(GrandTotal,2)

    LVL 28

    Accepted Solution

    Don't forget to include:

    Open in new window


    Author Closing Comment


    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
    In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
    In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now