Click here to Skip to main content
15,888,263 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

Please help me to write the correct SQL Expression for the following SQL statement.

SQL
SELECT COUNT(tblStu_Attendace.Status)
FROM tblStu_Attendace
GROUP BY tblStu_Attendace.StudentID
WHERE tblStu_Attendace.Status='P'


Thanks in advance.

EDIT (Comments moved from Answer)
This SQL Expression in Crystal Reports gives me error:

Error in SQL Expression:
Failed to retrieve data from database
Incorrect syntax near the keyword select
Posted
Updated 16-Mar-14 21:11pm
v2
Comments
Maciej Los 15-Mar-14 15:44pm    
You've got it!
What's the question?

Check the order of commands in your query.
Try
SQL
SELECT COUNT(tblStu_Attendace.Status)
FROM tblStu_Attendace
WHERE tblStu_Attendace.Status='P'
GROUP BY tblStu_Attendace.StudentID
 
Share this answer
 
This error actually occurs when I add the GROUP BY

EDIT
Right query should be like below
SQL
SELECT tblStu_Attendace.StudentID, COUNT(tblStu_Attendace.Status)
FROM tblStu_Attendace
GROUP BY tblStu_Attendace.StudentID
WHERE tblStu_Attendace.Status='P'
 
Share this answer
 
v2

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



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