简单的查询语句

查询student表中的所有记录
select * from student

检查student表中的所有记录的sname,Ssex和class
select sname,ssex,class from student

查询老师所有的单位即不重复的depart列
select distinct depart from teacher;

查询socre表中成绩在从68到80之间的记录
select * from score where degree between 60 and 80;

查询score表成绩中为85、86或88
select * from score where degree in(85,86,88)

查询student表中“95031”班或性别为“女”同学的同学记录
select * from student where class=“95031” or ssex=“女”

以class降序查询student表的所有记录
select * from student order by class desc

以cno升序。degree降序查询score表的所有记录
select *from score order by cno asc,degree desc

查询“95031”班学生人数
select count(*) from student where class=“95031”

查询score表中的最高分的学生学号和课程号(子查询或者排序)
select sno,cno from score where degree=(select max(degree) from score)
select sno,cno from score order by degree desc limit 0,1

.查看每门课的平均成绩 (分组查询)
select avg(degree) from score where cno=“3-105”

查询score表中至少有2名同学选修的并以3开头的课程的平均分数 havimg(组级过滤)

select cno,avg(degree),count(*) from score
group by cno having count(cno)>=2 and cno like ‘3%’;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值