我有一个查询和显示,它为我提供按部门分组的员工。它工作正常,但我还需要另外一件事我无法弄清楚。通过部门名称,我需要添加文字:“(x 员工)”,其中 x 是该部门的员工人数。例子:
MARKETING (2 employees)
John Doe
Jane Smith
我的代码如下:
<cfquery name="getEmpsByDept" datasource="#application.DSN#" dbtype="ODBC">
SELECT DISTINCT First, Last, Department
FROM SuccessFactorsPeople
ORDER BY Department
</cfquery>
<table border="0" width="70%" cellpadding="0" cellspacing="0">
<cfoutput query="getEmpsByDept" group="Department">
<tr>
<td><b>#Ucase(Department)#</b></td>
</tr>
<cfoutput>
<tr>
<td> #TRIM(First)# #TRIM(Last)#</td>
</tr>
</cfoutput>
<tr>
<td height="0"> </td>
</tr>
</cfoutput>
</table>