adding values from recordset

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
LVL 5
cempashaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
DragonlairdConnect With a Mentor Commented:
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
 
rohanbairat3Commented:
I think if you provide a group by clause in your SQL that should solve it. Else you have to calculate it manually.
0
 
cempashaAuthor Commented:
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
 
DragonlairdCommented:
Hehe - it's usually the simple answers that elude the best of us... Glad we could help
0
All Courses

From novice to tech pro — start learning today.