Creating Output Using the GROUP Parameter

To create pages like Figure 10.7, you use an ORDER BY clause in your <CFQUERY> in conjunction with the GROUP parameter in your <CFOUTPUT> statement. Recall that ORDER BY causes the results of your query to be returned in a certain order, arranging records alphabetically or numerically by the field you specify.

Note

ColdFusion's GROUP output parameter only works properly if you've supplied an ORDER BY statement in your SQL query. In order for <CFOUTPUT> to accurately group a set of records, it must receive the records pre-ordered by the "grouped" field.

The GROUP parameter then takes over in a template's <CFOUTPUT> section to arrange ordered records into definable groups. To illustrate, look at the code ...

Get Sams Teach Yourself ColdFusion® in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.