一个评分系统。
不同的学生或督导可以给教师打分。  教师最后的总分为 学生打分(平均分)的 50% 与 督导打分(平均分)的 50% 相加。
现设:
A表中有 stuno(学生学号)   tno(教师工号)   score(教师得分)B表中有 dno(督导学号)     tno(教师工号)   score(教师得分)请问 如何 实时统计(每有一条数据录入就自动统计)   每个 教师的 最后得分啊???

解决方案 »

  1.   

    select a.tno, avg(a.score)*0.05+avg(b.score)*0.5 as num from A表 a, B表 b where a.tno=b.tno group by a.tno
      

  2.   

    select a.tno, avg(a.score)*0.5+avg(b.score)*0.5 as num from A表 a, B表 b where a.tno=b.tno group by a.tno
      

  3.   

    select tno,sum(score) as score
    from
    (
    select tno,avg(score)*0.5 as score from a
    union all
    select tno,avg(score)*0.5 as score from b
    ) t
    group by tno可能会存在学生有打分但是督导没打分,或督导打了分但学生没打分的情况