Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO SUM A FIELD VALUE FROM A TABLE

Status
Not open for further replies.

alexfusion

Programmer
Feb 5, 2001
94
AR
Hello everyone,
This is a simple question:
I have a table with a field containing tax values in each row.
I have to sum all of this field values to get a total value.
That's fine.The problem is when one particular field is empty.Of course I doing an aritmethic operation with an empty field and I get an error.
Could anyone tell me how to solve this problem so if the field is empty the value to add is 0?

Many thanks

alexfusion

mixale@hotmail.com
 
try something like this:

<cfparam name=&quot;total&quot; default=&quot;0&quot;>

now, put this in the query loop:

<cfif queryValue EQ &quot;&quot;>
<cfset newQueryValue = &quot;0&quot;>
<cfset total = total + newQueryValue>
<cfelse>
<cfset newQueryValue = queryValue>
<cfset total = total + newQueryValue>
</cfif>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top