1、查询Student表中的所有记录的Sname、Ssex和Class列。
SELECT sname,ssex,class
from student
2、 查询教师所有的单位即不重复的Depart列。
备注:不去重查到的教师所有depart
select depart
FROM teacher
去重查到的教师所有的depart
select DISTINCT depart
FROM teacher
3、查询Student表的所有记录。
select *
from student
4、查询Score表中成绩在60到80之间的所有记录。
-- 方法一
SELECT *
from score
where degree >= 60 and degree <= 80
-- 方法二
SELECT *
from score
where degree BETWEEN 60 and 80
5、查询Score表中成绩为85,86或88的记录。
-- 方法二
select *
from score
where degree in (85,86,88)
-- 方法一
select *
from score
where degree = 85 or degree = 86 or degree = 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、查询“95033”班的学生人数。
SELECT class,count(*) total
from student
where CLASS='95033'