以一个学生在2004-04-01至2004-04-08的其间为例:1、保存学生出勤情况到数据库或文本文件,时间以time()或date('Y-m-d',time())均可。
2、读取学生在一个时间起止段(在2004-04-01至2004-04-08都符合)中各种考勤情况出现的次数。
3、把2中相应的次数*分值再求和即可完成你的要求。

解决方案 »

  1.   

    select stu_id, sum(if(stu_s='正常',1,if(stu_s='迟到',-0.5,if(stu_s='请假',-0.5,if(stu_s='早退',-0.5,-1))))) stu_sum from student where (stu_date between '2004-5-1' and '2004-5-31') and stu_id=1 group by stu_id
      

  2.   

    哦,看错题了。select stu_id, sum(s_score)
    from student,stat
    where stu_s = s_id
    where (stu_date between '2004-5-1' and '2004-5-31') and stu_id=1 
    group by stu_id