Calculating Database fields

1. Rene Guest

## Calculating Database fields

I need to calculate fields that are being pulled from a database.<BR>ex:<BR>Quantity = 2 Price = \$85.00<BR>Quantity = 1 Price = \$75.00 <BR><BR>I want to calculate Quantity * Price and then add up that amount for a total. Can any one help out.

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## RE: Calculating Database fields

&#060;TABLE Width="100%" Border=1 CellPadding=5&#062;<BR>&#060;%<BR>Set RS = yourConnection.Execute "SELECT * FROM table"<BR><BR>total = 0.0<BR>Do Until RS.EOF<BR>&nbsp; &nbsp; qty = RS("Quantity")<BR>&nbsp; &nbsp; prc = RS("Price")<BR>&nbsp; &nbsp; extension = qty * prc<BR>&nbsp; &nbsp; total = total + extension<BR>%&#062;<BR>&nbsp; &nbsp; &#060;TR&#062;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &#060;TD align=right&#062;&#060;% = qty %&#062;&#060;/TD&#062;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &#060;TD align=right&#062;&#060;% = FormatCurrency(prc) %&#062;&#060;/TD&#062;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &#060;TD align=right&#062;&#060;% = FormatCurrency(extension) %&#062;&#060;/TD&#062;<BR>&nbsp; &nbsp; &#060;/TR&#062;<BR>&#060;%<BR>&nbsp; &nbsp; RS.MoveNext<BR>Loop<BR>%&#062;<BR>&#060;TR&#062;<B R>&nbsp; &nbsp; &#060;TD colspan=2 align=right&#062;Total:&#060;/TD&#062;<BR>&nbsp; &nbsp; &#060;TD align=right&#062;&#060;% = FormatCurrency(Total) %&#062;&#060;/TD&#062;<BR>&#060;/TR&#062;<BR>&#060;/TABLE&#062;<BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•