gpt4 book ai didi

coldfusion - 如何使用 cfoutput group by date 输出表格结果?

转载 作者:行者123 更新时间:2023-12-03 11:20:42 26 4
gpt4 key购买 nike

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

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>

最佳答案

您走在正确的轨道上,但遗漏了一个细节。 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 标签。

关于coldfusion - 如何使用 cfoutput group by date 输出表格结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24147088/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com