SELECT
Student.id,
Student.first_name,
Student.last_name,
count(`Attendance`.`id`) as total
FROM `karate`.`attendances` AS `Attendance`
RIGHT JOIN `karate`.`students` AS `Student` ON (`Attendance`.`student_id` = `Student`.`id`)
WHERE 1
AND `Attendance`.`attendance_date` BETWEEN '2012-07-01' AND '2012-07-31'
AND (Student.active = '1')
AND (Student.type = 'student')
GROUP BY `Student`.`id`
ORDER BY total ASC
我希望所有学生记录在给定的日期范围内有出勤总数,但它只显示有出勤的学生的两个记录。但如果我们删除日期检查条件,它工作正常。
提前致谢