1、查詢教師所有的單位即不重復的Depart列 select distinct depart from teacher 2、查詢Score表中成績在60到80之間的所有記錄 select * from score where degree between 60 and 80 3、查詢Score表中成績?yōu)?5,86或88的記錄 select * from score where degree in (85,86,88) 4、查詢Student表中“95031”班或性別為“女”的同學記錄 select * from student where class='95031' or ssex ='女' 5、以Cno升序、Degree降序查詢Score表的所有記錄 select * from score order by cno,degree desc 6、查詢“95031”班的學生人數(shù) select count(*) from student where class='95031' 或者:select count(*) as scount from student where class='95031' ---查詢結果另取列名 為scount 展示 7、查詢Score表中的最高分的學生學號和課程號 select sno,cno from score where degree=(select max(degree) from score) 8、查詢每門課的平均成績 select cno,avg(degree) from score group by cno 9、查詢Score表中至少有5名學生選修的并以3開頭的課程的平均分數(shù) select cno,avg(degree) from score group by cno having count(*)>=5 and cno like'3%' 10、查詢所有學生的Sname、Cno和Degree列 select sname,cno,degree from student,score where student.sno=score.sno 或者:select sname,cno,degree from score join student on score.sno = student.sno 11、查詢所有學生的Sname、Cname和Degree列 select sname,cname,degree from student,course,score where student.sno = score.sno and score.cno=course.cno 或者:select sname,cname,degree from score join student on student.sno=score.sno join course on score.cno = course.cno |
|