Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SELECT  a.RegNo ,a.Attendance ,COUNT(a.Attendance )AtCount
FROM 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 3
An 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 )AtCount
FROM 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 3
An 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.
Posted
Updated 4-Sep-17 20:32pm

Try this
SELECT  a.RegNo ,a.Attendance ,COUNT(a.Attendance )AtCount
FROM 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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900