我认为您可以使用 group 属性,如下所示
<cfset myQuery = QueryNew("Section, State, Data", "VarChar, VarChar, VarChar")>
<cfset newRow = QueryAddRow(MyQuery, 5)>
<!--- Set the values of the cells in the query --->
<cfset temp = QuerySetCell(myQuery, "Section", "Section 1", 1)>
<cfset temp = QuerySetCell(myQuery, "State", "State 1", 1)>
<cfset temp = QuerySetCell(myQuery, "Data", "Data 1", 1)>
<cfset temp = QuerySetCell(myQuery, "Section", "Section 1", 2)>
<cfset temp = QuerySetCell(myQuery, "State", "State 2", 2)>
<cfset temp = QuerySetCell(myQuery, "Data", "Data 2", 2)>
<cfset temp = QuerySetCell(myQuery, "Section", "Section 1", 3)>
<cfset temp = QuerySetCell(myQuery, "State", "State 2", 3)>
<cfset temp = QuerySetCell(myQuery, "Data", "Data 3", 3)>
<cfset temp = QuerySetCell(myQuery, "Section", "Section 2", 4)>
<cfset temp = QuerySetCell(myQuery, "State", "State 2", 4)>
<cfset temp = QuerySetCell(myQuery, "Data", "Data 2", 4)>
<cfset temp = QuerySetCell(myQuery, "Section", "Section 2", 5)>
<cfset temp = QuerySetCell(myQuery, "State", "State 2", 5)>
<cfset temp = QuerySetCell(myQuery, "Data", "Data 3", 5)>
<cfoutput query ="myQuery" group="Section">
</br>#Section# <!--- You will get distinct Sections here --->
<cfoutput group="Section">
</br>#State#,
<cfoutput>#Data#,</cfoutput>
</cfoutput>
</cfoutput>