Re: [SQL ] SQL练习题

楼主: shomingchang ( )   2013-12-31 07:00:32
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, 科目, 分数 ),
: 资料内容如下图例:
: "学生"资料表 "成绩"资料表
:
作者: brian70545 (SoccerMan)   0000-00-00 00:00:00
要乱数的话 " target="_blank" rel="nofollow">

Links booklink

Contact Us: admin [ a t ] ucptt.com