本文介绍了加入计数功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT tbl_Departments.DepartmentID,tbl_Departments.DepartmentName,count(tbl_LabourDetails.DepartmentID) as labor
FROM tbl_LabourDetails RIGHT OUTER JOIN
tbl_Departments ON tbl_LabourDetails.DepartmentID = tbl_Departments.DepartmentID
我试过这样但有一个例外:
列'tbl_Departments.DepartmentID'在选择列表,因为它不包含在聚合函数或GROUP BY子句中。
解决方案
SELECT tbl_Departments.DepartmentID, tbl_Departments.DepartmentName, count(tbl_LabourDetails.DepartmentID ) as labour FROM tbl_LabourDetails RIGHT OUTER JOIN tbl_Departments ON tbl_LabourDetails.DepartmentID = tbl_Departments.DepartmentID
I have tried like this but there is an exception:
Column 'tbl_Departments.DepartmentID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
解决方案
这篇关于加入计数功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!