SQL经典练习题48道之二(11-19)

接上篇SQL经典练习题48道之一
11、查询“95031”班的学生人数。
答:
select COUNT(sno) from student where classnum=’95031’;
12、查询Score表中的最高分的学生学号和课程号。
答:
select sno,cno from score where degree =(select max(degree) from score);
13、查询‘3-105’号课程的平均分。
答:
select avg(degree) from score where cno=’3-105’;
14、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。
答:
select cno,avg(degree) from score where cno in(select cno from score where cno like ‘3%’ group by cno having count(*)>4);
15、查询最低分大于70,最高分小于90的Sno列。
答:
select sno,max(degree),min(degree) from score group by sno having min(degree)>70 and max(degree)<90;
16、查询所有学生的Sname、Cno和Degree列。
答:
select sname,cno,degree from score s left join student st on s.sno=st.sno;
17、查询所有学生的Sno、Cname和Degree列。
答:
select sno,cname,degree from score s left join course c on s.cno=c.cno;
18、查询所有学生的Sname、Cname和Degree列。
答:
select sname,cname,degree from score s left join student st on s.sno=st.sno left join course c on s.cno=c.cno;
19、查询“95033”班所选课程的平均分。
答:
select avg(degree) from score where sno in(select sno from student where classnum=’95033’);

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值