Solved

adding values from recordset

Posted on 2006-07-06
4
256 Views
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
0
Comment
Question by:cempasha
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
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...
0
 
LVL 7

Expert Comment

by:rohanbairat3
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.
0
 
LVL 5

Author Comment

by:cempasha
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
0
 
LVL 6

Expert Comment

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

19 Experts available now in Live!

Get 1:1 Help Now