• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Using Databases > Grouping Data with <cfoutput>

Grouping Data with <cfoutput>

<cfoutput> also can be used to group data according to a specific column for reporting purposes by using the group attribute. <cfoutput> does not sort data, so the data in the query object must already be appropriately ordered. After group is specified, the <cfoutput> statement loops only once per distinct value in the grouped column. A second, nested <cfoutput> statement can be used to loop over every record in a particular group, including the first record in the group:

<!--- order results by department --->
<cfquery name="users" datasource="dsn">
SELECT EmpID, LastName, FirstName, Phone, DeptID
FROM users
ORDER BY DeptID
</cfquery>


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint