1.查询XS表中的所有列。
select * from xs
2.查询XS表中计算机专业同学的学号、姓名和总学分。
select 学号,姓名,总学分
from xs
where 专业='计算机'
'
3.查询XS表中计算机专业同学的学号、姓名和总学分,结果中各列的标题分别指定为number、
name和mark。
select 学号 as number,姓名 as name,总学分 as mark
from xs
where 专业='计算机'
4.查询XS表中通信工程专业总学分大于等于42的学生情况。select *
from xs
where 专业='通信工程' and 总学分>=42
5.查询XS表中姓“王”且单名的学生情况。
Select *
from xs
where 姓名 like '王_'
6.查询XS表中不在1979年出生的学生情况。
select *
from xs
where 出生时间<'1979' or 出生时间>'1980'
7.查询选修了课程号为101的学生情况。
select *
from xs
where 学号 in (select 学号    from xs_kc    where 课程号='101')
8.查询未选修离散数学的学生情况。
select *
from xs
where not exists ( select *
from xs_kc,kc
where xs.学号=xs_kc.学号 and xs_kc.课程号=kc.课程号
and kc.课程名='离散数学')
9.查询比所有计算机系的学生年龄都大的学生情况
select *
from xs
where 出生时间<(select min(出生时间)
from xs
where 专业='计算机')
10.查询选修了全部课程的同学的姓名。
select 姓名
from xs
where not exists (select *
from kc
where not exists (select *
from xs_kc
where xs.学号=xs_kc.学号 and
kc.课程号=xs_kc.课程号)) 结果为空
11.查询选修了学号001102同学所选修的全部课程的同学学号。
select distinct 学号
from xs_kc as A
where not exists(select *
from xs_kc as B
where B.学号='001102' and not exists
( select *
from xs_kc as C
where A.学号=C.学号 and B.课程号=C.课程号))
12.查询选修了206课程且成绩在80分以上的学生姓名及成绩。
select xs.姓名 ,xs_kc.成绩
from xs,xs_kc,kc
where xs.学号=xs_kc.学号 and kc.课程号=xs_kc.课程号 and kc.课程号='206' and xs.学号 in (select 学号
from xs_kc
where 课程号='206' and 成绩>80)
13. 查询选修了“计算机基础”课程且成绩在80分以上的学生学号、姓名、课程名及成绩。select xs.学号,xs.姓名,kc.课程名,xs_kc.成绩
from xs, kc,xs_kcsql查询面试题
where xs.学号=xs_kc.学号 and kc.课程号=xs_kc.课程号 and 课程名='计算机基础'  and 成绩>80
14.查询至少选修两门课且成绩相同的学生学号、课程号和成绩。
select A.学号 ,A.课程号,A.成绩
from XS_KC as A,XS_KC as B
where A.学号=B.学号 and A.课程号!=B.课程号 and A.成绩=B.成绩