I have a query that get the all the employees count in a table:
emp_namelast | emp_namefirst | employeetotal | year_cse1
--------------------------------------------------------
smith | john | 13 | 2014
smith jr | jonnny | 10 |2014
baker |jane |5 |2015
doe |john |6 |2015
I'm outputting the results in a table. I have the results in order from the query. But with the code below it's outputting the top result from 2014 and then the top result from 2015.
I have tried using no group , which gives me all the data from the query. I would like it to output the data from 2014 and 2015 in two different tables. One would contain records for 2014 and the other 2015.
Would it have to be done without using a 'group'?
<h2>employees</h2>
<table >
<thead><tr><th>Employee</th><th>Stars</th></tr></thead>
<tbody>
<cfoutput query="GetEmployeeTotals" group="year_cse1">
<tr><td>#emp_namefirst# #emp_namelast#</td>
<td>#employeetotal#</td>
</tr>
</cfoutput>
</tbody>
</table>
You are on the right track but are missing a detail. The group attribute works like this:
<cfoutput query="somequery" group="somefield">
grouped data goes here
<cfoutput>
ungrouped data goes here
</cfoutput>
grouped data can go here as well
</cfoutput>
In your code, you are not outputting any grouped data, and you are missing the extra cfoutput tags for the ungrouped data.