|
[code=sql]--1. 如果用下列命令会得到什么结果
Select * from STUDENT;
--查询STUDENT的所有记录
--2. 请找出居住在下列地区的每个学生的平均成绩
--ATLANTA
--NEW ORLEANS
--SEOUL
select b.Student_Name,AVG(a.gpa) as Gpa_avg
from GPA as a
join Student as b
on a.Student_ID = b.Student_ID
where b.City in ('ATLANTA', 'NEW ORELEANS', 'SEOUL')
group by b.Student_Name
--3.请列出在2006年Fall学期中选修MGS8020课程得到最高GPA的同学的ID和名字
select b.Student_ID,b.Student_Name
from GPA as a
join Student as b
on a.Student_ID = b.Student_ID
where [Year]=2006 and Semester = 'Fall' and Course_ID = 'MGS 8020'
and GPA = (select MAX(gpa) from GPA
where [Year]=2006 and Semester = 'Fall' and Course_ID = 'MGS 8020')
--4.请列出在2009年Spring学期中选修MGS8020课程的所有同学的ID和名字
select a.Student_ID,a.Student_Name
from Student as a
join GPA as b
on a.Student_ID = b.Student_ID
where [Year]=2009 and Semester = 'Spring' and Course_ID = 'MGS 8020' [/code] |
|