Using Aggregate Functions - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

The following example is not case-sensitive; it uses the
'sylvester', 'SYLVESTER', and so on as all lowercase, and matches them with the all lowercase
string, 'sylvester':
SELECT dog_name
FROM Dogs
WHERE LOWER(dog_name) LIKE 'sylvester';
If you use a variable on the right side of the LIKE conditional and want to ensure that the
comparison is not case-sensitive, use the
all of one case, as in the following example:
WHERE LOWER(dog_name) LIKE '#LCase(FORM.SearchString)#';
Escaping wildcards
You can specify your own escape character using the conditional ESCAPE clause.
Example
The following example uses the ESCAPE clause to enable a search for a literal percent sign (%),
which ColdFusion normally interprets as a wildcard character:
SELECT emp_discount
FROM Benefits
WHERE emp_discount LIKE '10\%'
ESCAPE '\';

Using aggregate functions

Aggregate functions operate on a set of data and return a single value. Use these functions for
retrieving summary information from a table, as opposed to retrieving an entire table and then
operating on the record set of the entire table.
Consider using aggregate functions to perform the following operations:
To display the average of a column
To count the number of rows for a column
To find the earliest date in a column
Since not every relational database management system (RDBMS) supports all aggregate
functions, refer to your database's documentation. The following table lists the aggregate
functions that ColdFusion supports:
Function
AVG()
COUNT()
MAX()
MIN()
SUM()
Syntax
aggregate_func ::= <COUNT>(* | column_name) | AVG | SUM | MIN | MAX)
([ALL | DISTINCT] numeric_exp)
468
Chapter 22: Using Query of Queries
Description
Returns the average (mean) for a column.
Returns the number of rows in a column.
Returns the largest value of a column.
Returns the lowest value of a column.
Returns the sum of values of a column.
LOWER()
or
function to force the variable text to be
LCase
UCase
function to treat 'Sylvester',

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents