Solved

adding values from recordset

Posted on 2006-07-06
4
277 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with stored procedure 30 66
Update field in order 21 143
Classic ASP application Will support SQL 2014 5 87
FileUp - Classic ASP 5 17
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…
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/…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

803 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