columnTotal(qryColumn)
Last updated May 13, 2003
Version: 2 | Requires: ColdFusion 5 | Library: DataManipulationLib
Description:
With this UDF, you can get the total of all rows for any given query column. Assuming of course that the column you specify contains numbers! :-)
Return Values:
Returns a number.
Example:
<cfset queryAddRow(foo,10)>
<cfloop index="x" from=1 to=10>
<cfset querySetCell(foo,"total",x,x)>
</cfloop>
<cfoutput>#columnTotal("foo.total")#</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| qryColumn | The name and column of the query, i.e. foo.total | Yes |
Full UDF Source:
<cfscript>
/**
* This UDF calculates the total of a column from a query.
* Version 2 by Raymond Camden
*
* @param qryColumn The name and column of the query, i.e. foo.total (Required)
* @return Returns a number.
* @author Scott Barber (charlesbarber@hotmail.com)
* @version 2, May 13, 2003
*/
function columnTotal(qryColumn){
return arraySum(listToArray(evaluate("valueList(" & qryColumn & ")")));
}
</cfscript>
Search CFLib.org
Latest Additions
Dave Anderson added
iniToStruct
20 day(s) ago
Dave Anderson added
deDupeArray
20 day(s) ago
Richard added
dice
22 day(s) ago
Isaac Dealey added
getRelative
a while ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)