select Selected_Student.student_ID,Selected_Student.name,sum(SCORE.score) as '
總分', avg(SCORE.score) as '平均' from ((select * from STUDENT where grade=1
limit 100) union
(select * from STUDENT where grade=2 limit 100) union
(select * from STUDENT where grade=3 limit 100) union
(select * from STUDENT where grade=4 limit 100) union
(select * from STUDENT where grade=5 limit 100) union
(select * from STUDENT where grade=6 limit 100)) as Selected_Student inner
join SCORE on Selected_Student.student_ID = SCORE.student_ID group by
Selected_Student.student_ID
※ 引述《john9872 (菸酒生)》之銘言:
: 假設我有兩個資料表,分別為"學生"及"成績",
: 資料欄位分別為: ( student_ID, 姓名, 年級 ) 及
: ( 成績流水號, student_ID, 科目, 分數 ),
: 資料內容如下圖例:
: "學生"資料表 "成績"資料表
: