adding values from recordset

Posted on 2006-07-06
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

Dragonlaird earned 250 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

Technology Partners: 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 recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

628 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