I have two tables: Attendance Table
ID student_roll sem class_id
1 314 7 1
2 315 7 1
3 316 7 1
4 314 7 2
5 315 7 2
6 314 7 3
7 315 7 3
8 316 7 3
9 314 7 4
10 315 7 4
11 316 7 4
Class Table
class_id course t_id date
1 MC 2 14/3/14
2 MC 2 15/3/14
3 C 2 16/3/14
4 MC 2 17/3/14
In the attendance table you can see that roll no. 316 is absent in class_id 2.So suppose i want to count the no of class attended by roll no. 316 in a particular course (Here MC) how can i do so? please help me with the query...Thanks in advance:)
The following query will return the number of attendance records for a particular student (ie. student roll 316), with respect to a given class (ie. 'MC')
SELECT COUNT(*) as ClassCount
FROM attendance A
INNER JOIN class_table C
ON A.class_id = C.class_id
WHERE A.student_roll = 316
AND C.course = 'MC'
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments