Go Premium for a chance to win a PS4. Enter to Win


adding values from recordset

Posted on 2006-07-06
Medium Priority
Last Modified: 2008-01-09
hi all
i have a recordset which lists customers spendings in form of

| itemname     |  quantity    |     itemprice    |     totalprice  |

the rest i can get it without any problem but i dont know how to get the total of it. i can get the sum from sql statement however quantity is not calculated that way so its not useful for me.

is there a way to get the total for all the items listed ? thanks in advance
Question by:cempasha
  • 2

Accepted Solution

Dragonlaird earned 1000 total points
ID: 17051069
I'm not entirely sure what you're trying to achieve...

Usually I'd submit a separate SQL query to retrieve the Sum of the fields if that was all I wanted because DB servers are much faster at calculating totals than ASP and this would also drastically reduce the amount of data being transferred (over a network?) to perform the calculation.

If you're using a loop to iterate through the recordset (say, to display them as a table?) then simply use variables to keep a running total as you process each record...

Expert Comment

ID: 17051206
I think if you provide a group by clause in your SQL that should solve it. Else you have to calculate it manually.

Author Comment

ID: 17051225
thanks for both comments. i dont know why i couldnt think of it before :)) i have done as dragonlaird mentioned

>>If you're using a loop to iterate through the recordset (say, to display them as a table?) then simply use variables to keep a running total as you process each record...

thanks again

Expert Comment

ID: 17051493
Hehe - it's usually the simple answers that elude the best of us... Glad we could help

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

876 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