我想更新表A中的collunm(CSEReduxResponses)。 collumn将为'AVERAGE',它将属于表CSEReduxResponses。 我有一个获得总开始次数的查询
<cfquery datasource="Intranet" name="GroupStars">
SELECT execoffice_status, employeedept, COUNT(*) as 'totalstars'
FROM CSEReduxResponses
WHERE execoffice_status = 1
GROUP BY execoffice_status, employeedept
</cfquery>
在这个其他查询中,我有总计数
<cfif GetTotalStars.RecordCount gt 0>
<cfquery datasource="PhoneList" name="GetAllData">
SELECT dept.csedept_id, COUNT(*) as 'totalcount'
FROM employee, dept
WHERE employee.dept_id = dept.dept_id
AND employee.emp_status = 1
AND dept.csedept_id is not null
GROUP BY dept.csedept_id
</cfquery>
获得'AVERAGE'我会将totalstars / totalcount和那个答案分开 进入'AVERAGE'Collumn, 我如何加入这两张桌子并获得平均值?
答案 0 :(得分:0)
<cfset avg = GroupStars.totalstars / GetAllData.totalcount>
<cfquery name="qUpdateAvg" datasource="Intranet">
UPDATE CSEReduxResponses
SET AVERAGE = <cfqueryparam value="#avg#" cfsqltype="cf_sql_integer">
WHERE execoffice_status = 1
</cfquery>
将cfsqltype更改为您的实际列类型。