P
Puma Wang
Unregistered / Unconfirmed
GUEST, unregistred user!
都没有人全答对?
1:根据学生名查出该学生所选的课程。
Select c.cName
From student s, course c ,sc
Where s.sName ='Puma' and sc.sn =s.sn and c.cn=sc.cn
2:根据课程名查出所有选这门课的学生。
Select s.sName
From student s, course c ,sc
Where c.cName ='Chemist' and sc.sn =s.sn and c.cn=sc.cn
3:选出选课最多的学生名。
Select st.sname
From student st ,(Select sc.sn ,count(*) as cc from sc Group by sc.sn) s ,
(Select top 1 sn,count(*) as cc From sc Group by sn) ssc
Where st.sn=s.sn and s.cc =ssc.cc
4:选出最多人报名的课程名。
Select cs.cName,s.cc
From course cs ,(Select sc.cn ,count(*) as cc From sc Group by sc.cn) s ,
(Select top 1 cn,count(*) as cc From sc Group by cn) ssc
Where cs.cn=s.cn and s.cc =ssc.cc
5:显示课程名的选课排行榜,按照报名的人数。
Select cs.cname,ssc.cc
From course cs,(Select cn,count(*) as cc From sc Group by cn) as ssc
Where cs.cn =ssc.cn
Order by ssc.cc desc
呵呵,肯定全对。比较好玩的题目!!
1:根据学生名查出该学生所选的课程。
Select c.cName
From student s, course c ,sc
Where s.sName ='Puma' and sc.sn =s.sn and c.cn=sc.cn
2:根据课程名查出所有选这门课的学生。
Select s.sName
From student s, course c ,sc
Where c.cName ='Chemist' and sc.sn =s.sn and c.cn=sc.cn
3:选出选课最多的学生名。
Select st.sname
From student st ,(Select sc.sn ,count(*) as cc from sc Group by sc.sn) s ,
(Select top 1 sn,count(*) as cc From sc Group by sn) ssc
Where st.sn=s.sn and s.cc =ssc.cc
4:选出最多人报名的课程名。
Select cs.cName,s.cc
From course cs ,(Select sc.cn ,count(*) as cc From sc Group by sc.cn) s ,
(Select top 1 cn,count(*) as cc From sc Group by cn) ssc
Where cs.cn=s.cn and s.cc =ssc.cc
5:显示课程名的选课排行榜,按照报名的人数。
Select cs.cname,ssc.cc
From course cs,(Select cn,count(*) as cc From sc Group by cn) as ssc
Where cs.cn =ssc.cn
Order by ssc.cc desc
呵呵,肯定全对。比较好玩的题目!!