1

我正在统计学生对教师的评价。我希望我的结果显示为:

Instructor1 -   145
Instructor2 -    23
Instructor3 -   394

#CountInstructor# 没有改变。只有第一个计数是正确的。

使用 Coldfusion 8。
感谢您的帮助。

<CFQUERY NAME="GetAll" datasource="eval" dbtype="ODBC">
SELECT ID, Instructor, Q1, Q2, Q3, Q4, Q5, Q6
FROM data
</CFQUERY>
<CFQUERY NAME="GetInstructor" datasource="eval" dbtype="ODBC">
SELECT DISTINCT Instructor
FROM data
ORDER BY Instructor
</CFQUERY>

<cfset myInstructor = ValueList(GetInstructor.Instructor)>
<cfset myCountInstructor = ValueList(GetAll.Instructor)>
<cfset CountInstructor = ListValueCount(myCountInstructor, myInstructor)> 

<cfoutput query="GetAll">
  <cfset CountInstructor = ListValueCount(myCountInstructor, GetInstructor.Instructor)> 
  #GetInstructor.Instructor#  - #CountInstructor# <br />
</cfoutput>
4

2 回答 2

0

您在查询输出循环中使用 ListValueCount() 对您没有任何帮助。你到底想做什么?如果您只想随时输出计数...

<cfoutput query="GetInstructor">
    #GetInstructor.Instructor# - #GetInstructor.CurrentRow#
</cfoutput>

否则,我只是不确定您要做什么(并且您需要限定所有变量的范围,包括查询名称)。

于 2013-09-26T17:24:19.987 回答
0
<cfoutput query="GetInstructor">
   <cfset CountInstructor = ListValueCount(myCountInstructor, GetInstructor.Instructor)> 
    #GetInstructor.Instructor#  - #CountInstructor# <br />
</cfoutput>
于 2013-10-18T13:56:56.983 回答