(最后),我想总结与同USER_ID行(用于列思考,我不需要有其他的列,只USER_ID与思考)琛一行相同的ID(MySQL的)
我查询
SELECT students_group.user_id,scores.result ,exam.name,exam.ponderation,exam.id, (scores.result * exam.ponderation)/totpond.totalpond as ponderation
from (
select sum(exam.ponderation) as totalpond from scores
left join exam on exam.id = scores.exam_id
left join teacher_group on teacher_group.id = exam.teacher_group_id
left join groups on groups.id = teacher_group.group_school_id
left join students_group on students_group.user_id = scores.user_id
where teacher_group.id = 54
group by students_group.user_id
) as totpond,scores
left join exam on exam.id = scores.exam_id
left join teacher_group on teacher_group.id = exam.teacher_group_id
left join groups on groups.id = teacher_group.group_school_id
left join students_group on students_group.user_id = scores.user_id
where teacher_group.id = 54
group by scores.id
order by students_group.user_id
的是它可以做到这一点与我的查询或需要使用PHP?有人能帮助我吗 ? THX :)
最后,sorrry – user1029834 2011-12-14 18:02:27