user2455594
user2455594

Reputation: 1

mysql query how to sum attendance status values

I am new to mysql. In the above table i have to SUM attendance_status(column) depending on the date like

01/05/2013 att_stat=0
01/05/2013 att_stat=1
02/05/2013 att_stat=0
02/05/2013 att_stat=1

It's working pretty well when thr is only 3 record when I insert 4th one its not working

SELECT SUM(Attendance_Status) as total FROM student_attendance1 Where Attendance_Status='1' and Date= '"+datevalue+"'";'

Upvotes: 0

Views: 223

Answers (1)

Deval Shah
Deval Shah

Reputation: 1094

Basically you are close just have to put GROUP BY

SELECT
  SUM(Attendance_Status) AS total
FROM student_attendance1
WHERE Attendance_Status = '1'
    AND DATE = '"+datevalue+"'"
GROUP BY DATE 

Upvotes: 3

Related Questions