coldfusioncfmlcfquerycfloop

ColdFusion - Output Grouping From a Query


I have a great question that is probably bone-head simple. I have the following query:

<cfquery name="getempareview" dbtype="query">
  SELECT firstname,lastname,deptname,supcode
  FROM getreviews
  WHERE supcode IN (#preserveSingleQuotes(setsupcode)#)
</cfquery>

What I need to do is output so that the supcode has the other data under it in a list. So, if I have 100 rows of data and the supcode is the same on 25 of the records, just have the following:

supcode firstname lastname - deptname (all 25 records would be listed out here)

Any help would be greatly appreciated.


Solution

  • Nested outputs. Try this.

    <cfoutput query="YourQueryName" group="SupCode">
    <h2>#SupCode#</h2>
    <cfoutput>
    #FirstName# #LastName# <br/>
    </cfoutput>
    
    </cfoutput>