0

我是mysql的新手。在上表中,我必须SUM attendance_status(column) 取决于日期

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

当我插入第 4 条记录时它只有 3 条记录时它工作得很好

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

1 回答 1

3

基本上你很接近只需要放GROUP BY

SELECT
  SUM(Attendance_Status) AS total
FROM student_attendance1
WHERE Attendance_Status = '1'
    AND DATE = '"+datevalue+"'"
GROUP BY DATE 
于 2013-06-05T12:32:13.473 回答