(最後),我想總結與同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