<!--- 
 Filename: qofqcast.cfm
 Created by: Raymond Camden (ray@camdenfamily.com)
 Purpose: Demonstrates using the cast function.
--->

<cfset x = queryNew("data","varchar")>
<cfset queryAddRow(x)>
<cfset querySetCell(x,"data",200)>
<cfset queryAddRow(x)>
<cfset querySetCell(x,"data",300)>
<cfset queryAddRow(x)>
<cfset querySetCell(x,"data",400)>
<cfset queryAddRow(x)>
<cfset querySetCell(x,"data",100)>

<cfquery name="test" dbtype="query">
  SELECT SUM(CAST(data AS INTEGER)) AS total
  FROM x
</cfquery>

<cfoutput>The sum was #test.total#</cfoutput>