10-281 查询前3门课程的课号及课程名称
select cno,cname from course limit 3;
10-282 查询2050年所有学生的姓名及年龄,要求结果中列名显示中文
select sname as 姓名,2050-year(bday) as 年龄
from students
10-283 查询至2050年所有年龄小于等于55岁的女生的学号和姓名
select sno as 学号,sname as 姓名,ssex as 性别
from students
where ssex = '女' and year(bday) >= 1995
10-284 查询“信息学院”的学生姓名、性别和出生日期
select sname,ssex,bday
from students
where sdept ='信息学院';
10-285 查询Students表中的所有系名,要求结果中系名不重复
select distinct sdept from students;
10-286 查询“0000010”课程的课名、先修课号和学分
select cname,cpno,ccredit
from course
where cno='0000010';
10-287 查询成绩在80~90分之间的选课成绩情况
select *
from sc
where score >= 80 and score <= 90;
10-288 查询成绩为69分、79分或89分的记录
select * from sc where score in (69,79,89);
10-289 查询在1970年1月1日之前出生的男教师信息
select *
from teachers
where tbirthday <= '1970-01-01' and tsex = '男';
10-290 输出有成绩的学生学号和课号
select sno,cno from sc where score is not null;
10-291 查询所有姓“刘”的学生信息
select * from students
where sname like '刘%';
10-292 查询生源地不是“山东”省的学生信息
select * from students
where bplace not like '山东%';
10-293 查询名字中含有“明”字的男生的学生姓名和班级
select sname,class
from students
where sname like '%明%' and ssex='男';
10-294 查询姓名是两个字的学生信息
select * from students where sname like '__';
10-295 查询非信息学院和机电学院的学生信息
select * from students
where sdept not in ('信息学院','机电学院');
10-296 查询学生表中没有联系电话的学生信息
select * from students
where phone is null;
10-297 从学生表统计总的学生人数
select count(*) as 人数 from students ;
10-298 统计有学生选修的课程的门数,多人选修同一门只算一门
select count(distinct cno) as 门数 from sc ;
10-299 计算“0000001”课程的平均分、最高分和最低分
select avg(score) 平均分,max(score) 最高分,min(score) 最低分
from sc
where cno='0000001';
10-300 查询各个课程号及相应的选课人数
select cno 课程号,count(*) 选课人数
from sc
group by 课程号