pta mysql训练题集(281-300)

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 课程号

  • 5
    点赞
  • 42
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三块不一样的石头

十分满意,一分打赏~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值