 <cffunction name="count" returntype="numeric" access="public" output="false" hint="Returns the number of rows that match the arguments (or all rows if no arguments are passed in). Uses the SQL function `COUNT`. If no records can be found to perform the calculation on, `0` is returned."
 	examples=
 	'
-		<!--- Count how many authors there are in the table --->
-		<cfset authorCount = model("author").count()>
-
-		<!--- Count how many authors that have a last name starting with an "A" --->
-		<cfset authorOnACount = model("author").count(where="lastName LIKE ''A%''")>
-
-		<!--- Count how many authors that have written books starting with an "A" --->
-		<cfset authorWithBooksOnACount = model("author").count(include="books", where="booktitle LIKE ''A%''")>
-		
-		<!--- Count the number of comments on a specific post (a `hasMany` association from `post` to `comment` is required) --->
-		<!--- The `commentCount` method will call `model("comment").count(where="postId=##post.id##")` internally --->
-		<cfset aPost = model("post").findByKey(params.postId)>
-		<cfset amount = aPost.commentCount()>
+		// Count how many authors there are in the table
+		authorCount = model("author").count();
+
+		// Count how many authors that have a last name starting with an "A"
+		authorOnACount = model("author").count(where="lastName LIKE ''A%''");
+
+		// Count how many authors that have written books starting with an "A"
+		authorWithBooksOnACount = model("author").count(include="books", where="booktitle LIKE ''A%''");
+
+		// Count the number of comments on a specific post (a `hasMany` association from `post` to `comment` is required)
+		// The `commentCount` method will call `model("comment").count(where="postId=##post.id##")` internally
+		aPost = model("post").findByKey(params.postId);
+		amount = aPost.commentCount();
 	'
 	categories="model-class,statistics" chapters="column-statistics,associations" functions="average,hasMany,maximum,minimum,sum">
 	<cfargument name="where" type="string" required="false" default="" hint="See documentation for @findAll.">

				loc.properties = ListAppend(loc.properties, variables.wheels.class.calculatedProperties[loc.item].sql);
			}
		}
		arguments.select = arguments.select & loc.properties;

		// alias the result with `AS`, this means that Wheels will not try and change the string (which is why we have to add the table name above since it won't be done automatically)
		arguments.select = arguments.select & ") AS wheelsqueryresult";

		// call `findAll` with `select`, `where`, `parameterize` and `include` but delete all other arguments
		StructDelete(arguments, "type");
		StructDelete(arguments, "property");
		StructDelete(arguments, "distinct");
		
		loc.rv = findAll(argumentCollection=arguments).wheelsqueryresult;
		if (!Len(loc.rv) && Len(arguments.ifNull))
		{

<cffunction name="average" returntype="any" access="public" output="false" hint="Calculates the average value for a given property. Uses the SQL function `AVG`. If no records can be found to perform the calculation on you can use the `ifNull` argument to decide what should be returned."
	examples=
	'
		// Get the average salary for all employees
		avgSalary = model("employee").average("salary");

		// Get the average salary for employees in a given department
		avgSalary = model("employee").average(property="salary", where="departmentId=##params.key##");

		// Make sure a numeric value is always returned if no records are calculated
		avgSalary = model("employee").average(property="salary", where="salary BETWEEN ##params.min## AND ##params.max##", ifNull=0);
	'
	categories="model-class,statistics" chapters="column-statistics" functions="count,maximum,minimum,sum">
	<cfargument name="property" type="string" required="true" hint="Name of the property to calculate the average for.">
