-- 1 、 查询 Student表中的所有记录的Sname、Ssex和Class 列。
select sname,ssex,class from student;
-- 2 、 查询教师所有的单位即不重复的 Depart 列。
select depart,group_concat(tname) from teacher group by depart;
-- 3 、 查询 Student 表的所有记录。
Select*fromstudent;
-- 4 、 查询 Score表中成绩在60到80 之间的所有记录。
Select * from score where degree between 60 an 80;
-- 5 、 查询 Score表中成绩为85,86或88 的记录。
Select * from score where degree in (85,86,88);
-- 6 、 查询 Student表中"95031"班或性别为"?" 的同学记录。
Select * from student where class=’95031’ or ssex=’女’;
-- 7 、 以 Class降序查询Student 表的所有记录。
Select * from student order by class desc;
-- 8 、 以 Cno升序、Degree降序查询Score 表的所有记录。
Select * from score order by cno asc,degree desc;
-- 9 、 查询 "95031" 班的学??数。
Select count(*) from student where class=’95031’
-- 10 、 查询 Score 表中的最?分的学?学号和课程号。(?查询或者排序)
Select sno,cno from score where degree=(select Max(degree) from score);
-- 10.1 查询Score表中除了每?课程最?分的学?学号和课程号。(?查询或者排序)
Select sno,cno from score where degree not in (select Max(degree) from score group by cno);
拔?题: -- 11、查询每?课的平均成绩。 -- 12、查询Score表中?少有5名学?选修的并以3开头的课程的平均分数。 -- 13、查询分数?于70,?于90的Sno列。 -- 14、查询所有学?的Sname、Cno和Degree列。 -- 15、查询所有学?的Sno、Cname和Degree列。 -- 16、查询所有学?的Sname、Cname和Degree列。 -- 17、查询"95033"班学?的平均分。
MySQL练习
标签:esc date 不重复 group hda loading datetime mic img