2

我有一个查询可以获取表中的所有员工数:

emp_namelast | emp_namefirst | employeetotal | year_cse1
--------------------------------------------------------
smith        | john          | 13            | 2014
smith jr     | jonnny        | 10            |2014
baker        |jane           |5              |2015
doe           |john           |6             |2015

我在表格中输出结果。我按查询的顺序排列了结果。但是使用下面的代码,它会输出 2014 年的最高结果,然后是 2015 年的最高结果。

我尝试使用 no group ,它为我提供了查询中的所有数据。我希望它在两个不同的表中输出 2014 年和 2015 年的数据。一个将包含 2014 年和另一个 2015 年的记录。

是否必须在不使用“组”的情况下完成?

<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>
4

1 回答 1

6

您走在正确的轨道上,但缺少一个细节。group 属性的工作方式如下:

<cfoutput query="somequery" group="somefield">
grouped data goes here

<cfoutput>
ungrouped data goes here
</cfoutput>
grouped data can go here as well
</cfoutput>

在您的代码中,您没有输出任何分组数据,并且您缺少未分组数据的额外 cfoutput 标记。

于 2014-06-10T17:26:29.013 回答