MySQL练习题

-- 1、 查询Students表中的Sname、Ssex和Class列。select SNAME,SSEX,CLASS from students;-- 2、 查询教师所有的单位即不重复的Depart列。select distinct depart from teachers;-- 3、 查询Students表的所有记录。select * from students;-- 4、 查询Scores表中成绩在60到80之间的所有记录。select * from scores where DEGR
摘要由CSDN通过智能技术生成
-- 1、 查询Students表中的Sname、Ssex和Class列。
select SNAME,SSEX,CLASS from students;
-- 2、 查询教师所有的单位即不重复的Depart列。
select distinct depart from teachers;
-- 3、 查询Students表的所有记录。
select * from students;
-- 4、 查询Scores表中成绩在60到80之间的所有记录。
select * from scores where DEGREE>60 and DEGREE <80;
select * from scores where DEGREE between 60 and 80;
-- 5、 查询Scores表中成绩为85,86或88的记录。
select * from scores where DEGREE=85 or DEGREE =86 or DEGREE =88;
select * from scores where DEGREE in (85,86,88);
-- 6、 查询Students表中“95031”班或性别为“女”的同学记录。
select * from students where CLASS=95031 or SSEX='女';
-- 7、 以Class降序查询Students表的所有记录。
select * from students ORDER BY CLASS desc;
-- 8、 以Cno升序查询Scores表的所有记录。
select * from scores ORDER BY CNO;
-- 9、 查询“95031”班的学生人数。
select count(*) from students WHERE CLASS=95031;
-- 10、查询Scores表中的最高分的学生学号和课程号。
select SNO,CNO from scores order by DEGREE desc limit 1;
-- 11、查询‘3-105’号课程的平均分。
select avg(DEGREE) from scores where CNO='
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值