Solved

# Customert

Posted on 2011-10-03
241 Views
Hi,
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
0
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'
UNION ALL
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

Then

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

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

0

LVL 28

Accepted Solution

Don't forget to include:
``````<%
rs.MoveNext
LOOP
%>
``````
0

Author Closing Comment

Awesome
0

## Featured Post

### Suggested Solutions

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 …