SQL经典练习题48道之七(41-48)

接上篇 SQL经典练习题48道之六(36-40)
41、查询Student表中最大和最小的Sbirthday日期值。
答:
select max(sbirthday),min(sbirthday) from student;
42、以班号和年龄从大到小的顺序查询Student表中的全部记录。
答:
select * from student order by classnum desc,sbirthday asc;
43、查询“男”教师及其所上的课程。
答:
select * from course where tno in(select tno from teacher where tsex=’男’);
44、查询最高分同学的Sno、Cno和Degree列。
答:
select sno,cno,degree from score where degree=(select MAX(degree) from score);
45、查询和“李军”同性别的所有同学的Sname.
答:
select sname from student where ssex=(select ssex from student where sname=’李军’);
46、查询和“李军”同性别并同班的同学Sname.
答:
select sname from student where ssex=(select ssex from student where sname=’李军’) and classnum=(select classnum from student where sname=’李军’);
47、查询所有选修“计算机导论”课程的“男”同学的成绩表
答:
select * from score where cno=(select cno from course where cname=’计算机导论’) and sno in (select sno from student where ssex=’男’);
48、查询最高分同学的Sname、Cno和Degree列。
答:
select sname,cno,degree from (select sno,cno,degree from score where degree=(select MAX(degree) from score) )s1 left join student s2 on s1.sno=s2.sno;

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值