本文介绍了聚合可能不会出现在WHERE子句中,除非它位于HAVING子句中包含的子查询中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 SELECT a.RegNo ,a.Attendance ,COUNT(a.Attendance )AtCountFROM Attendence as a WHERE Attdate BETWEEN '2017-07-17' AND '2017-08-01'and a.Attendance='A' group by a.Attendance,a.RegNo order by a.Attendance Msg 147, Level 15, State 1, Line 3An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference. 我尝试过: What I have tried:<pre>SELECT a.RegNo ,a.Attendance ,COUNT(a.Attendance )AtCountFROM Attendence as a WHERE Attdate BETWEEN '2017-07-17' AND '2017-08-01'and a.Attendance='A' group by a.Attendance,a.RegNo order by a.Attendance Msg 147, Level 15, State 1, Line 3An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference. 推荐答案 请参见此处: [ ^ ] 试试这个 Try thisSELECT a.RegNo ,a.Attendance ,COUNT(a.Attendance )AtCountFROM Attendence as a WHERE Attdate BETWEEN '2017-07-17' AND '2017-08-01'group by a.Attendance,a.RegNo HAVING a.Attendance='A' order by a.Attendance 这篇关于聚合可能不会出现在WHERE子句中,除非它位于HAVING子句中包含的子查询中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-14 05:40