Tuesday, March 01, 2005

ColdFusion: Group By

The following code produces groupings by Division, with the given Division as a label for the group. However, each group contains ALL the employees, regardless of the Division they are in. What do I have to do to have only employees in the given Division listed under that Division?

<cfif #Division# EQ "#Division#">#Division#<br>
<cfloop query="ThirtyYearAwards">#FirstName# #MiddleName# #LastName# #Division#'<br>
</cfloop>
</cfif><br/>
</cfoutput>

I would greatly appreciate your help. :-)

You'll want to use the "group" attribute of cfoutput.

<cfoutput query="ThirtyYearAwards" group="Division">#Division#<br/>
<cfoutput>
#FirstName# #MiddleName# #LastName#<br/>
</cfoutput>
</cfoutput>

0 Comments:

Post a Comment

<< Home